diff --git a/plugin/think-plugs-wemall/stc/database/20230404000001_install_wemall.php b/plugin/think-plugs-wemall/stc/database/20230404000001_install_wemall.php index bff4397cf..280b9571c 100644 --- a/plugin/think-plugs-wemall/stc/database/20230404000001_install_wemall.php +++ b/plugin/think-plugs-wemall/stc/database/20230404000001_install_wemall.php @@ -14,6 +14,7 @@ // | github 代码仓库:https://github.com/zoujingli/think-plugs-wemall // +---------------------------------------------------------------------- +use think\admin\extend\PhinxExtend; use think\migration\Migrator; @set_time_limit(0); @@ -74,36 +75,26 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_config_agent() { - - // 当前数据表 - $table = 'plugin_wemall_config_agent'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_agent', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-等级', - ]) - ->addColumn('name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '级别名称']) - ->addColumn('cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '等级图标']) - ->addColumn('cardbg', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '等级卡片']) - ->addColumn('number', 'integer', ['limit' => 2, 'default' => 0, 'null' => true, 'comment' => '级别序号']) - ->addColumn('upgrade_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '升级规则(0单个,1同时)']) - ->addColumn('extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '升级规则']) - ->addColumn('remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '级别描述']) - ->addColumn('utime', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '更新时间']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '等级状态(1使用,0禁用)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('utime', ['name' => 'i6a80c4b9e_utime']) - ->addIndex('status', ['name' => 'i6a80c4b9e_status']) - ->addIndex('number', ['name' => 'i6a80c4b9e_number']) - ->addIndex('create_time', ['name' => 'i6a80c4b9e_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '级别名称']], + ['cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '等级图标']], + ['cardbg', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '等级卡片']], + ['number', 'integer', ['limit' => 2, 'default' => 0, 'null' => true, 'comment' => '级别序号']], + ['upgrade_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '升级规则(0单个,1同时)']], + ['extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '升级规则']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '级别描述']], + ['utime', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '更新时间']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '等级状态(1使用,0禁用)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'utime', 'status', 'number', 'create_time', + ]); } /** @@ -114,45 +105,34 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_config_coupon() { - - // 当前数据表 - $table = 'plugin_wemall_config_coupon'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_coupon', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-卡券', - ]) - ->addColumn('type', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '类型(0通用券,1商品券)']) - ->addColumn('name', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '优惠名称']) - ->addColumn('cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '封面图标']) - ->addColumn('extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '扩展数据']) - ->addColumn('content', 'text', ['default' => NULL, 'null' => true, 'comment' => '内容描述']) - ->addColumn('remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '系统备注']) - ->addColumn('amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '抵扣金额']) - ->addColumn('limit_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '金额门槛(0不限制)']) - ->addColumn('limit_levels', 'string', ['limit' => 180, 'default' => '-', 'null' => true, 'comment' => '授权等级']) - ->addColumn('limit_times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '限领数量(0不限制)']) - ->addColumn('expire_days', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '有效天数']) - ->addColumn('total_stock', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '库存数量']) - ->addColumn('total_sales', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '发放数量']) - ->addColumn('total_used', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '使用数量']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '卡券状态(0禁用,1使用)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('sort', ['name' => 'ibfe2b6128_sort']) - ->addIndex('type', ['name' => 'ibfe2b6128_type']) - ->addIndex('status', ['name' => 'ibfe2b6128_status']) - ->addIndex('deleted', ['name' => 'ibfe2b6128_deleted']) - ->addIndex('create_time', ['name' => 'ibfe2b6128_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['type', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '类型(0通用券,1商品券)']], + ['name', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '优惠名称']], + ['cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '封面图标']], + ['extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '扩展数据']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '内容描述']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '系统备注']], + ['amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '抵扣金额']], + ['limit_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '金额门槛(0不限制)']], + ['limit_levels', 'string', ['limit' => 180, 'default' => '-', 'null' => true, 'comment' => '授权等级']], + ['limit_times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '限领数量(0不限制)']], + ['expire_days', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '有效天数']], + ['total_stock', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '库存数量']], + ['total_sales', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '发放数量']], + ['total_used', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '使用数量']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '卡券状态(0禁用,1使用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'sort', 'type', 'status', 'deleted', 'create_time', + ]); } /** @@ -163,33 +143,23 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_config_discount() { - - // 当前数据表 - $table = 'plugin_wemall_config_discount'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_discount', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-折扣', - ]) - ->addColumn('name', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '方案名称']) - ->addColumn('remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '方案描述']) - ->addColumn('items', 'text', ['default' => NULL, 'null' => true, 'comment' => '方案规则']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '方案状态(0禁用,1使用)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('sort', ['name' => 'i8d0e0158e_sort']) - ->addIndex('status', ['name' => 'i8d0e0158e_status']) - ->addIndex('deleted', ['name' => 'i8d0e0158e_deleted']) - ->addIndex('create_time', ['name' => 'i8d0e0158e_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['name', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '方案名称']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '方案描述']], + ['items', 'text', ['default' => NULL, 'null' => true, 'comment' => '方案规则']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '方案状态(0禁用,1使用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'sort', 'status', 'deleted', 'create_time', + ]); } /** @@ -200,37 +170,27 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_config_level() { - - // 当前数据表 - $table = 'plugin_wemall_config_level'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_level', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-等级', - ]) - ->addColumn('name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '级别名称']) - ->addColumn('cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '等级图标']) - ->addColumn('cardbg', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '等级卡片']) - ->addColumn('number', 'integer', ['limit' => 2, 'default' => 0, 'null' => true, 'comment' => '级别序号']) - ->addColumn('upgrade_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '升级规则(0单个,1同时)']) - ->addColumn('upgrade_team', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '团队人数统计(0不计,1累计)']) - ->addColumn('remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '用户级别描述']) - ->addColumn('extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '配置规则']) - ->addColumn('utime', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '更新时间']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '等级状态(1使用,0禁用)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('utime', ['name' => 'if851bb0b1_utime']) - ->addIndex('status', ['name' => 'if851bb0b1_status']) - ->addIndex('number', ['name' => 'if851bb0b1_number']) - ->addIndex('create_time', ['name' => 'if851bb0b1_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '级别名称']], + ['cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '等级图标']], + ['cardbg', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '等级卡片']], + ['number', 'integer', ['limit' => 2, 'default' => 0, 'null' => true, 'comment' => '级别序号']], + ['upgrade_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '升级规则(0单个,1同时)']], + ['upgrade_team', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '团队人数统计(0不计,1累计)']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '用户级别描述']], + ['extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '配置规则']], + ['utime', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '更新时间']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '等级状态(1使用,0禁用)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'utime', 'status', 'number', 'create_time', + ]); } /** @@ -241,41 +201,28 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_config_notify() { - - // 当前数据表 - $table = 'plugin_wemall_config_notify'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_notify', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-通知', - ]) - ->addColumn('code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '通知编号']) - ->addColumn('name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '通知标题']) - ->addColumn('cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '通知图片']) - ->addColumn('levels', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '用户等级']) - ->addColumn('content', 'text', ['default' => NULL, 'null' => true, 'comment' => '通知内容']) - ->addColumn('remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '通知描述']) - ->addColumn('num_read', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '阅读次数']) - ->addColumn('tips', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => 'TIPS显示']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('code', ['name' => 'i0614c3468_code']) - ->addIndex('sort', ['name' => 'i0614c3468_sort']) - ->addIndex('name', ['name' => 'i0614c3468_name']) - ->addIndex('tips', ['name' => 'i0614c3468_tips']) - ->addIndex('status', ['name' => 'i0614c3468_status']) - ->addIndex('deleted', ['name' => 'i0614c3468_deleted']) - ->addIndex('create_time', ['name' => 'i0614c3468_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '通知编号']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '通知标题']], + ['cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '通知图片']], + ['levels', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '用户等级']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '通知内容']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '通知描述']], + ['num_read', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '阅读次数']], + ['tips', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => 'TIPS显示']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'sort', 'name', 'tips', 'status', 'deleted', 'create_time', + ]); } /** @@ -286,39 +233,27 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_config_poster() { - - // 当前数据表 - $table = 'plugin_wemall_config_poster'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_poster', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-海报', - ]) - ->addColumn('code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '推广编号']) - ->addColumn('name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '推广标题']) - ->addColumn('levels', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '用户等级']) - ->addColumn('devices', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '接口通道']) - ->addColumn('image', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '推广图片']) - ->addColumn('content', 'text', ['default' => NULL, 'null' => true, 'comment' => '二维位置']) - ->addColumn('remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '推广描述']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('code', ['name' => 'ib84148924_code']) - ->addIndex('sort', ['name' => 'ib84148924_sort']) - ->addIndex('name', ['name' => 'ib84148924_name']) - ->addIndex('status', ['name' => 'ib84148924_status']) - ->addIndex('deleted', ['name' => 'ib84148924_deleted']) - ->addIndex('create_time', ['name' => 'ib84148924_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '推广编号']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '推广标题']], + ['levels', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '用户等级']], + ['devices', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '接口通道']], + ['image', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '推广图片']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '二维位置']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '推广描述']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'sort', 'name', 'status', 'deleted', 'create_time', + ]); } /** @@ -329,56 +264,38 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_config_rebate() { - - // 当前数据表 - $table = 'plugin_wemall_config_rebate'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_rebate', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-返利', - ]) - ->addColumn('type', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '奖励类型']) - ->addColumn('code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '配置编号']) - ->addColumn('name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '配置名称']) - ->addColumn('path', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '等级关系']) - ->addColumn('stype', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '结算类型(0支付结算,1收货结算)']) - ->addColumn('p0_level', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '会员等级']) - ->addColumn('p1_level', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '上1级等级']) - ->addColumn('p2_level', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '上2级等级']) - ->addColumn('p3_level', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '上3级等级']) - ->addColumn('p0_reward_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '会员计算类型(0固定金额,1交易比例,2利润比例)']) - ->addColumn('p0_reward_number', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '会员计算系数']) - ->addColumn('p1_reward_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '上1级计算类型(0固定金额,1交易比例,2利润比例)']) - ->addColumn('p1_reward_number', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '上1级计算系数']) - ->addColumn('p2_reward_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '上2级计算类型(0固定金额,1交易比例,2利润比例)']) - ->addColumn('p2_reward_number', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '上2级计算系数']) - ->addColumn('p3_reward_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '上3级计算类型(0固定金额,1交易比例,2利润比例)']) - ->addColumn('p3_reward_number', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '上3级计算系数']) - ->addColumn('remark', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '配置描述']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('code', ['name' => 'i3a0d023e7_code']) - ->addIndex('sort', ['name' => 'i3a0d023e7_sort']) - ->addIndex('name', ['name' => 'i3a0d023e7_name']) - ->addIndex('type', ['name' => 'i3a0d023e7_type']) - ->addIndex('stype', ['name' => 'i3a0d023e7_stype']) - ->addIndex('status', ['name' => 'i3a0d023e7_status']) - ->addIndex('deleted', ['name' => 'i3a0d023e7_deleted']) - ->addIndex('p1_level', ['name' => 'i3a0d023e7_p1_level']) - ->addIndex('p2_level', ['name' => 'i3a0d023e7_p2_level']) - ->addIndex('p3_level', ['name' => 'i3a0d023e7_p3_level']) - ->addIndex('p0_level', ['name' => 'i3a0d023e7_p0_level']) - ->addIndex('create_time', ['name' => 'i3a0d023e7_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['type', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '奖励类型']], + ['code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '配置编号']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '配置名称']], + ['path', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '等级关系']], + ['stype', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '结算类型(0支付结算,1收货结算)']], + ['p0_level', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '会员等级']], + ['p1_level', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '上1级等级']], + ['p2_level', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '上2级等级']], + ['p3_level', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '上3级等级']], + ['p0_reward_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '会员计算类型(0固定金额,1交易比例,2利润比例)']], + ['p0_reward_number', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '会员计算系数']], + ['p1_reward_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '上1级计算类型(0固定金额,1交易比例,2利润比例)']], + ['p1_reward_number', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '上1级计算系数']], + ['p2_reward_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '上2级计算类型(0固定金额,1交易比例,2利润比例)']], + ['p2_reward_number', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '上2级计算系数']], + ['p3_reward_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '上3级计算类型(0固定金额,1交易比例,2利润比例)']], + ['p3_reward_number', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '上3级计算系数']], + ['remark', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '配置描述']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'sort', 'name', 'type', 'stype', 'status', 'deleted', 'p1_level', 'p2_level', 'p3_level', 'p0_level', 'create_time', + ]); } /** @@ -389,35 +306,23 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_express_company() { - - // 当前数据表 - $table = 'plugin_wemall_express_company'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_express_company', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-快递-公司', - ]) - ->addColumn('code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '公司代码']) - ->addColumn('name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '公司名称']) - ->addColumn('remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '公司描述']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('code', ['name' => 'ia20ef923b_code']) - ->addIndex('sort', ['name' => 'ia20ef923b_sort']) - ->addIndex('name', ['name' => 'ia20ef923b_name']) - ->addIndex('status', ['name' => 'ia20ef923b_status']) - ->addIndex('deleted', ['name' => 'ia20ef923b_deleted']) - ->addIndex('create_time', ['name' => 'ia20ef923b_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '公司代码']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '公司名称']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '公司描述']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'sort', 'name', 'status', 'deleted', 'create_time', + ]); } /** @@ -428,37 +333,25 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_express_template() { - - // 当前数据表 - $table = 'plugin_wemall_express_template'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_express_template', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-快递-模板', - ]) - ->addColumn('code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '模板编号']) - ->addColumn('name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '模板名称']) - ->addColumn('normal', 'text', ['default' => NULL, 'null' => true, 'comment' => '默认规则']) - ->addColumn('content', 'text', ['default' => NULL, 'null' => true, 'comment' => '模板规则']) - ->addColumn('company', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '快递公司']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('code', ['name' => 'i415af662e_code']) - ->addIndex('sort', ['name' => 'i415af662e_sort']) - ->addIndex('name', ['name' => 'i415af662e_name']) - ->addIndex('status', ['name' => 'i415af662e_status']) - ->addIndex('deleted', ['name' => 'i415af662e_deleted']) - ->addIndex('create_time', ['name' => 'i415af662e_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '模板编号']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '模板名称']], + ['normal', 'text', ['default' => NULL, 'null' => true, 'comment' => '默认规则']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '模板规则']], + ['company', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '快递公司']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'sort', 'name', 'status', 'deleted', 'create_time', + ]); } /** @@ -469,61 +362,45 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_goods() { - - // 当前数据表 - $table = 'plugin_wemall_goods'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_goods', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-内容', - ]) - ->addColumn('ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']) - ->addColumn('code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']) - ->addColumn('name', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '商品名称']) - ->addColumn('marks', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '商品标签']) - ->addColumn('cates', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '分类编号']) - ->addColumn('cover', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '商品封面']) - ->addColumn('slider', 'text', ['default' => NULL, 'null' => true, 'comment' => '轮播图片']) - ->addColumn('specs', 'text', ['default' => NULL, 'null' => true, 'comment' => '商品规格(JSON)']) - ->addColumn('content', 'text', ['default' => NULL, 'null' => true, 'comment' => '商品详情']) - ->addColumn('remark', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '商品描述']) - ->addColumn('stock_total', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品库存统计']) - ->addColumn('stock_sales', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品销售统计']) - ->addColumn('stock_virtual', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品虚拟销量']) - ->addColumn('price_selling', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最低销售价格']) - ->addColumn('price_market', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最低市场价格']) - ->addColumn('allow_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大积分兑换']) - ->addColumn('allow_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大余额支付']) - ->addColumn('rebate_type', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '参与返利(0无需返利,1需要返利)']) - ->addColumn('delivery_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '物流运费模板']) - ->addColumn('limit_lowvip', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '限制购买等级(0不限制,其他限制)']) - ->addColumn('limit_maxnum', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '最大购买数量(0不限制,其他限制)']) - ->addColumn('level_agent', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '推广权益(0无,1有)']) - ->addColumn('level_upgrade', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '购买升级等级(-1非入会,0不升级,其他升级)']) - ->addColumn('discount_id', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '折扣方案编号(0无折扣,其他折扣)']) - ->addColumn('num_read', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '访问阅读统计']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '列表排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '商品状态(1使用,0禁用)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('code', ['name' => 'i175165940_code']) - ->addIndex('sort', ['name' => 'i175165940_sort']) - ->addIndex('ssid', ['name' => 'i175165940_ssid']) - ->addIndex('status', ['name' => 'i175165940_status']) - ->addIndex('deleted', ['name' => 'i175165940_deleted']) - ->addIndex('rebate_type', ['name' => 'i175165940_rebate_type']) - ->addIndex('discount_id', ['name' => 'i175165940_discount_id']) - ->addIndex('create_time', ['name' => 'i175165940_create_time']) - ->addIndex('level_agent', ['name' => 'i175165940_level_agent']) - ->addIndex('level_upgrade', ['name' => 'i175165940_level_upgrade']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['name', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '商品名称']], + ['marks', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '商品标签']], + ['cates', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '分类编号']], + ['cover', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '商品封面']], + ['slider', 'text', ['default' => NULL, 'null' => true, 'comment' => '轮播图片']], + ['specs', 'text', ['default' => NULL, 'null' => true, 'comment' => '商品规格(JSON)']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '商品详情']], + ['remark', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '商品描述']], + ['stock_total', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品库存统计']], + ['stock_sales', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品销售统计']], + ['stock_virtual', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品虚拟销量']], + ['price_selling', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最低销售价格']], + ['price_market', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最低市场价格']], + ['allow_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大积分兑换']], + ['allow_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大余额支付']], + ['rebate_type', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '参与返利(0无需返利,1需要返利)']], + ['delivery_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '物流运费模板']], + ['limit_lowvip', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '限制购买等级(0不限制,其他限制)']], + ['limit_maxnum', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '最大购买数量(0不限制,其他限制)']], + ['level_agent', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '推广权益(0无,1有)']], + ['level_upgrade', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '购买升级等级(-1非入会,0不升级,其他升级)']], + ['discount_id', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '折扣方案编号(0无折扣,其他折扣)']], + ['num_read', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '访问阅读统计']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '列表排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '商品状态(1使用,0禁用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'sort', 'ssid', 'status', 'deleted', 'rebate_type', 'discount_id', 'create_time', 'level_agent', 'level_upgrade', + ]); } /** @@ -534,34 +411,24 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_goods_cate() { - - // 当前数据表 - $table = 'plugin_wemall_goods_cate'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_goods_cate', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-分类', - ]) - ->addColumn('pid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上级分类']) - ->addColumn('name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '分类名称']) - ->addColumn('cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '分类图标']) - ->addColumn('remark', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '分类描述']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '使用状态']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('pid', ['name' => 'i4e6868d55_pid']) - ->addIndex('sort', ['name' => 'i4e6868d55_sort']) - ->addIndex('status', ['name' => 'i4e6868d55_status']) - ->addIndex('deleted', ['name' => 'i4e6868d55_deleted']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['pid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上级分类']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '分类名称']], + ['cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '分类图标']], + ['remark', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '分类描述']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '使用状态']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'pid', 'sort', 'status', 'deleted', + ]); } /** @@ -572,45 +439,35 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_goods_item() { - - // 当前数据表 - $table = 'plugin_wemall_goods_item'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_goods_item', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-规格', - ]) - ->addColumn('gsku', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品SKU']) - ->addColumn('ghash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品哈希']) - ->addColumn('gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']) - ->addColumn('gspec', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '商品规格']) - ->addColumn('gunit', 'string', ['limit' => 10, 'default' => '件', 'null' => true, 'comment' => '商品单位']) - ->addColumn('gimage', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '商品图片']) - ->addColumn('stock_sales', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '销售数量']) - ->addColumn('stock_total', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品库存']) - ->addColumn('price_cost', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '进货成本']) - ->addColumn('price_selling', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '销售价格']) - ->addColumn('price_market', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '市场价格']) - ->addColumn('allow_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '兑换积分']) - ->addColumn('allow_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '余额支付']) - ->addColumn('reward_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励余额']) - ->addColumn('reward_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励积分']) - ->addColumn('number_virtual', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '虚拟销量']) - ->addColumn('number_express', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '计件系数']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '商品状态']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('gcode', ['name' => 'i65942f6de_gcode']) - ->addIndex('gspec', ['name' => 'i65942f6de_gspec']) - ->addIndex('ghash', ['name' => 'i65942f6de_ghash']) - ->addIndex('status', ['name' => 'i65942f6de_status']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['gsku', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品SKU']], + ['ghash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品哈希']], + ['gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['gspec', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '商品规格']], + ['gunit', 'string', ['limit' => 10, 'default' => '件', 'null' => true, 'comment' => '商品单位']], + ['gimage', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '商品图片']], + ['stock_sales', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '销售数量']], + ['stock_total', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品库存']], + ['price_cost', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '进货成本']], + ['price_selling', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '销售价格']], + ['price_market', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '市场价格']], + ['allow_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '兑换积分']], + ['allow_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '余额支付']], + ['reward_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励余额']], + ['reward_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励积分']], + ['number_virtual', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '虚拟销量']], + ['number_express', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '计件系数']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '商品状态']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'gcode', 'gspec', 'ghash', 'status', + ]); } /** @@ -621,29 +478,21 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_goods_mark() { - - // 当前数据表 - $table = 'plugin_wemall_goods_mark'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_goods_mark', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-标签', - ]) - ->addColumn('name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '标签名称']) - ->addColumn('remark', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '标签描述']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '标签状态(1使用,0禁用)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('sort', ['name' => 'i4dc56e1a2_sort']) - ->addIndex('status', ['name' => 'i4dc56e1a2_status']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '标签名称']], + ['remark', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '标签描述']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '标签状态(1使用,0禁用)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'sort', 'status', + ]); } /** @@ -654,34 +503,24 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_goods_stock() { - - // 当前数据表 - $table = 'plugin_wemall_goods_stock'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_goods_stock', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-库存', - ]) - ->addColumn('batch_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '操作批量']) - ->addColumn('ghash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品哈希']) - ->addColumn('gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']) - ->addColumn('gspec', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '商品规格']) - ->addColumn('gstock', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '入库数量']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '数据状态(1使用,0禁用)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('ghash', ['name' => 'ie71188985_ghash']) - ->addIndex('gcode', ['name' => 'ie71188985_gcode']) - ->addIndex('status', ['name' => 'ie71188985_status']) - ->addIndex('deleted', ['name' => 'ie71188985_deleted']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['batch_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '操作批量']], + ['ghash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品哈希']], + ['gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['gspec', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '商品规格']], + ['gstock', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '入库数量']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '数据状态(1使用,0禁用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'ghash', 'gcode', 'status', 'deleted', + ]); } /** @@ -692,40 +531,29 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_help_feedback() { - - // 当前数据表 - $table = 'plugin_wemall_help_feedback'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_help_feedback', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-意见-反馈', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '反馈用户']) - ->addColumn('phone', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '联系电话']) - ->addColumn('images', 'text', ['default' => NULL, 'null' => true, 'comment' => '反馈图片']) - ->addColumn('content', 'text', ['default' => NULL, 'null' => true, 'comment' => '反馈内容']) - ->addColumn('reply', 'text', ['default' => NULL, 'null' => true, 'comment' => '回复内容']) - ->addColumn('reply_st', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '回复状态']) - ->addColumn('reply_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '回复用户']) - ->addColumn('reply_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '回复时间']) - ->addColumn('sync', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '同步至常见问题状态(1已同步,0未同步)']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '展示状态(1使用,0禁用)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('sort', ['name' => 'i7fa1b82bf_sort']) - ->addIndex('unid', ['name' => 'i7fa1b82bf_unid']) - ->addIndex('status', ['name' => 'i7fa1b82bf_status']) - ->addIndex('deleted', ['name' => 'i7fa1b82bf_deleted']) - ->addIndex('reply_st', ['name' => 'i7fa1b82bf_reply_st']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '反馈用户']], + ['phone', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '联系电话']], + ['images', 'text', ['default' => NULL, 'null' => true, 'comment' => '反馈图片']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '反馈内容']], + ['reply', 'text', ['default' => NULL, 'null' => true, 'comment' => '回复内容']], + ['reply_st', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '回复状态']], + ['reply_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '回复用户']], + ['reply_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '回复时间']], + ['sync', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '同步至常见问题状态(1已同步,0未同步)']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '展示状态(1使用,0禁用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'sort', 'unid', 'status', 'deleted', 'reply_st', + ]); } /** @@ -736,35 +564,26 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_help_problem() { - - // 当前数据表 - $table = 'plugin_wemall_help_problem'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_help_problem', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-常见-问题', - ]) - ->addColumn('fid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => false, 'comment' => '来自反馈']) - ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '问题标题']) - ->addColumn('content', 'text', ['default' => NULL, 'null' => true, 'comment' => '问题内容']) - ->addColumn('num_er', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '未解决数']) - ->addColumn('num_ok', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '已解决数']) - ->addColumn('num_read', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '阅读次数']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '展示状态(1使用,0禁用)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('sort', ['name' => 'i2a4212540_sort']) - ->addIndex('status', ['name' => 'i2a4212540_status']) - ->addIndex('deleted', ['name' => 'i2a4212540_deleted']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['fid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => false, 'comment' => '来自反馈']], + ['name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '问题标题']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '问题内容']], + ['num_er', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '未解决数']], + ['num_ok', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '已解决数']], + ['num_read', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '阅读次数']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '展示状态(1使用,0禁用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'sort', 'status', 'deleted', + ]); } /** @@ -775,38 +594,26 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_help_question() { - - // 当前数据表 - $table = 'plugin_wemall_help_question'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_help_question', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-问答-内容', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '提问用户']) - ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '工单标题']) - ->addColumn('phone', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '联系电话']) - ->addColumn('order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '关联订单']) - ->addColumn('images', 'text', ['default' => NULL, 'null' => true, 'comment' => '工单图片']) - ->addColumn('content', 'text', ['default' => NULL, 'null' => true, 'comment' => '工单描述']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '工单状态(0取消,1新工单,2后台回复,3前台回复,4已完结)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('sort', ['name' => 'i9383b2cca_sort']) - ->addIndex('name', ['name' => 'i9383b2cca_name']) - ->addIndex('unid', ['name' => 'i9383b2cca_unid']) - ->addIndex('phone', ['name' => 'i9383b2cca_phone']) - ->addIndex('status', ['name' => 'i9383b2cca_status']) - ->addIndex('deleted', ['name' => 'i9383b2cca_deleted']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '提问用户']], + ['name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '工单标题']], + ['phone', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '联系电话']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '关联订单']], + ['images', 'text', ['default' => NULL, 'null' => true, 'comment' => '工单图片']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '工单描述']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '工单状态(0取消,1新工单,2后台回复,3前台回复,4已完结)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'sort', 'name', 'unid', 'phone', 'status', 'deleted', + ]); } /** @@ -817,33 +624,24 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_help_question_x() { - - // 当前数据表 - $table = 'plugin_wemall_help_question_x'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_help_question_x', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-问答-评论', - ]) - ->addColumn('ccid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '目标编号']) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']) - ->addColumn('content', 'text', ['default' => NULL, 'null' => true, 'comment' => '文本内容']) - ->addColumn('images', 'text', ['default' => NULL, 'null' => true, 'comment' => '图片内容']) - ->addColumn('reply_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '后台用户']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '记录状态(0无效,1待审核,2已审核)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('ccid', ['name' => 'i9180fa26f_ccid']) - ->addIndex('unid', ['name' => 'i9180fa26f_unid']) - ->addIndex('status', ['name' => 'i9180fa26f_status']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ccid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '目标编号']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '文本内容']], + ['images', 'text', ['default' => NULL, 'null' => true, 'comment' => '图片内容']], + ['reply_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '后台用户']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '记录状态(0无效,1待审核,2已审核)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'ccid', 'unid', 'status', + ]); } /** @@ -854,82 +652,62 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_order() { - - // 当前数据表 - $table = 'plugin_wemall_order'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_order', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-内容', - ]) - ->addColumn('ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']) - ->addColumn('puid1', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上1级代理']) - ->addColumn('puid2', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上2级代理']) - ->addColumn('puid3', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上3级代理']) - ->addColumn('order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']) - ->addColumn('order_ps', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '订单备注']) - ->addColumn('amount_cost', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品成本']) - ->addColumn('amount_real', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '实际金额']) - ->addColumn('amount_total', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '订单金额']) - ->addColumn('amount_goods', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品金额']) - ->addColumn('amount_profit', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '销售利润']) - ->addColumn('amount_reduct', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '随机减免']) - ->addColumn('amount_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '余额支付']) - ->addColumn('amount_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '积分抵扣']) - ->addColumn('amount_payment', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '金额支付']) - ->addColumn('amount_express', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '快递费用']) - ->addColumn('amount_discount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '折扣后金额']) - ->addColumn('coupon_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '优惠券编号']) - ->addColumn('coupon_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '优惠券金额']) - ->addColumn('allow_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大余额支付']) - ->addColumn('allow_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大积分抵扣']) - ->addColumn('ratio_integral', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '积分兑换比例']) - ->addColumn('number_goods', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品数量']) - ->addColumn('number_express', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '快递计数']) - ->addColumn('level_agent', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '升级代理等级']) - ->addColumn('level_member', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '升级会员等级']) - ->addColumn('rebate_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '返利金额']) - ->addColumn('reward_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励余额']) - ->addColumn('reward_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励积分']) - ->addColumn('payment_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '支付时间']) - ->addColumn('payment_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '支付状态(0未支付,1有支付)']) - ->addColumn('payment_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '实际支付']) - ->addColumn('delivery_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '物流类型(0无配送,1需配送)']) - ->addColumn('cancel_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '取消时间']) - ->addColumn('cancel_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '取消状态']) - ->addColumn('cancel_remark', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '取消描述']) - ->addColumn('deleted_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '删除时间']) - ->addColumn('deleted_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']) - ->addColumn('deleted_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '删除描述']) - ->addColumn('confirm_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '签收时间']) - ->addColumn('confirm_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '签收描述']) - ->addColumn('refund_code', 'string', ['limit' => 20, 'default' => NULL, 'null' => true, 'comment' => '售后单号']) - ->addColumn('refund_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '售后状态(0未售后,1预订单,2待审核,3待退货,4已退货,5待退款,6已退款,7已完成)']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '流程状态(0已取消,1预订单,2待支付,3待审核,4待发货,5已发货,6已收货,7已评论)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'i4914b9e88_unid']) - ->addIndex('ssid', ['name' => 'i4914b9e88_ssid']) - ->addIndex('puid1', ['name' => 'i4914b9e88_puid1']) - ->addIndex('puid2', ['name' => 'i4914b9e88_puid2']) - ->addIndex('puid3', ['name' => 'i4914b9e88_puid3']) - ->addIndex('status', ['name' => 'i4914b9e88_status']) - ->addIndex('order_no', ['name' => 'i4914b9e88_order_no']) - ->addIndex('create_time', ['name' => 'i4914b9e88_create_time']) - ->addIndex('refund_code', ['name' => 'i4914b9e88_refund_code']) - ->addIndex('coupon_code', ['name' => 'i4914b9e88_coupon_code']) - ->addIndex('delivery_type', ['name' => 'i4914b9e88_delivery_type']) - ->addIndex('cancel_status', ['name' => 'i4914b9e88_cancel_status']) - ->addIndex('refund_status', ['name' => 'i4914b9e88_refund_status']) - ->addIndex('deleted_status', ['name' => 'i4914b9e88_deleted_status']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['puid1', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上1级代理']], + ['puid2', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上2级代理']], + ['puid3', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上3级代理']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']], + ['order_ps', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '订单备注']], + ['amount_cost', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品成本']], + ['amount_real', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '实际金额']], + ['amount_total', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '订单金额']], + ['amount_goods', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品金额']], + ['amount_profit', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '销售利润']], + ['amount_reduct', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '随机减免']], + ['amount_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '余额支付']], + ['amount_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '积分抵扣']], + ['amount_payment', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '金额支付']], + ['amount_express', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '快递费用']], + ['amount_discount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '折扣后金额']], + ['coupon_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '优惠券编号']], + ['coupon_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '优惠券金额']], + ['allow_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大余额支付']], + ['allow_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大积分抵扣']], + ['ratio_integral', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '积分兑换比例']], + ['number_goods', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品数量']], + ['number_express', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '快递计数']], + ['level_agent', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '升级代理等级']], + ['level_member', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '升级会员等级']], + ['rebate_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '返利金额']], + ['reward_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励余额']], + ['reward_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励积分']], + ['payment_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '支付时间']], + ['payment_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '支付状态(0未支付,1有支付)']], + ['payment_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '实际支付']], + ['delivery_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '物流类型(0无配送,1需配送)']], + ['cancel_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '取消时间']], + ['cancel_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '取消状态']], + ['cancel_remark', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '取消描述']], + ['deleted_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '删除时间']], + ['deleted_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['deleted_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '删除描述']], + ['confirm_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '签收时间']], + ['confirm_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '签收描述']], + ['refund_code', 'string', ['limit' => 20, 'default' => NULL, 'null' => true, 'comment' => '售后单号']], + ['refund_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '售后状态(0未售后,1预订单,2待审核,3待退货,4已退货,5待退款,6已退款,7已完成)']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '流程状态(0已取消,1预订单,2待支付,3待审核,4待发货,5已发货,6已收货,7已评论)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'ssid', 'puid1', 'puid2', 'puid3', 'status', 'order_no', 'create_time', 'refund_code', 'coupon_code', 'delivery_type', 'cancel_status', 'refund_status', 'deleted_status', + ]); } /** @@ -940,34 +718,23 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_order_cart() { - - // 当前数据表 - $table = 'plugin_wemall_order_cart'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_order_cart', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-购物车', - ]) - ->addColumn('ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']) - ->addColumn('ghash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '规格哈希']) - ->addColumn('gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']) - ->addColumn('gspec', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '商品规格']) - ->addColumn('number', 'biginteger', ['limit' => 20, 'default' => 1, 'null' => true, 'comment' => '商品数量']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'i75d9c8693_unid']) - ->addIndex('ssid', ['name' => 'i75d9c8693_ssid']) - ->addIndex('gcode', ['name' => 'i75d9c8693_gcode']) - ->addIndex('gspec', ['name' => 'i75d9c8693_gspec']) - ->addIndex('ghash', ['name' => 'i75d9c8693_ghash']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['ghash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '规格哈希']], + ['gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['gspec', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '商品规格']], + ['number', 'biginteger', ['limit' => 20, 'default' => 1, 'null' => true, 'comment' => '商品数量']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'ssid', 'gcode', 'gspec', 'ghash', + ]); } /** @@ -978,70 +745,51 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_order_item() { - - // 当前数据表 - $table = 'plugin_wemall_order_item'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_order_item', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-商品', - ]) - ->addColumn('ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']) - ->addColumn('gsku', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品SKU']) - ->addColumn('ghash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品哈希']) - ->addColumn('gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']) - ->addColumn('gspec', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '商品规格']) - ->addColumn('gunit', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '商品单凭']) - ->addColumn('gname', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '商品名称']) - ->addColumn('gcover', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '商品封面']) - ->addColumn('order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']) - ->addColumn('stock_sales', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '包含商品数量']) - ->addColumn('amount_cost', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品成本单价']) - ->addColumn('price_market', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品市场单价']) - ->addColumn('price_selling', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品销售单价']) - ->addColumn('total_price_cost', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品成本总价']) - ->addColumn('total_price_market', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品市场总价']) - ->addColumn('total_price_selling', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品销售总价']) - ->addColumn('total_allow_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大余额支付']) - ->addColumn('total_allow_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大兑换总分']) - ->addColumn('total_reward_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品奖励余额']) - ->addColumn('total_reward_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品奖励积分']) - ->addColumn('level_code', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户等级序号']) - ->addColumn('level_name', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '用户等级名称']) - ->addColumn('level_agent', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '推广权益(0无,1有)']) - ->addColumn('level_upgrade', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '购买升级等级(-1非入会,0不升级,其他升级)']) - ->addColumn('rebate_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '参与返利状态(0不返,1返利)']) - ->addColumn('rebate_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '参与返利金额']) - ->addColumn('delivery_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递邮费模板']) - ->addColumn('delivery_count', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '快递计费基数']) - ->addColumn('discount_id', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '优惠方案编号']) - ->addColumn('discount_rate', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '100.000000', 'null' => true, 'comment' => '销售价格折扣']) - ->addColumn('discount_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品优惠金额']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '商品状态(1使用,0禁用)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'i16a8905b9_unid']) - ->addIndex('gsku', ['name' => 'i16a8905b9_gsku']) - ->addIndex('ssid', ['name' => 'i16a8905b9_ssid']) - ->addIndex('gcode', ['name' => 'i16a8905b9_gcode']) - ->addIndex('gspec', ['name' => 'i16a8905b9_gspec']) - ->addIndex('ghash', ['name' => 'i16a8905b9_ghash']) - ->addIndex('status', ['name' => 'i16a8905b9_status']) - ->addIndex('deleted', ['name' => 'i16a8905b9_deleted']) - ->addIndex('order_no', ['name' => 'i16a8905b9_order_no']) - ->addIndex('rebate_type', ['name' => 'i16a8905b9_rebate_type']) - ->addIndex('discount_id', ['name' => 'i16a8905b9_discount_id']) - ->addIndex('level_agent', ['name' => 'i16a8905b9_level_agent']) - ->addIndex('delivery_code', ['name' => 'i16a8905b9_delivery_code']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['gsku', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品SKU']], + ['ghash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品哈希']], + ['gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['gspec', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '商品规格']], + ['gunit', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '商品单凭']], + ['gname', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '商品名称']], + ['gcover', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '商品封面']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']], + ['stock_sales', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '包含商品数量']], + ['amount_cost', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品成本单价']], + ['price_market', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品市场单价']], + ['price_selling', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品销售单价']], + ['total_price_cost', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品成本总价']], + ['total_price_market', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品市场总价']], + ['total_price_selling', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品销售总价']], + ['total_allow_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大余额支付']], + ['total_allow_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大兑换总分']], + ['total_reward_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品奖励余额']], + ['total_reward_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品奖励积分']], + ['level_code', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户等级序号']], + ['level_name', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '用户等级名称']], + ['level_agent', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '推广权益(0无,1有)']], + ['level_upgrade', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '购买升级等级(-1非入会,0不升级,其他升级)']], + ['rebate_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '参与返利状态(0不返,1返利)']], + ['rebate_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '参与返利金额']], + ['delivery_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递邮费模板']], + ['delivery_count', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '快递计费基数']], + ['discount_id', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '优惠方案编号']], + ['discount_rate', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '100.000000', 'null' => true, 'comment' => '销售价格折扣']], + ['discount_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品优惠金额']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '商品状态(1使用,0禁用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'gsku', 'ssid', 'gcode', 'gspec', 'ghash', 'status', 'deleted', 'order_no', 'rebate_type', 'discount_id', 'level_agent', 'delivery_code', + ]); } /** @@ -1052,55 +800,42 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_order_refund() { - - // 当前数据表 - $table = 'plugin_wemall_order_refund'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_order_refund', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-售后', - ]) - ->addColumn('ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']) - ->addColumn('type', 'biginteger', ['limit' => 20, 'default' => 1, 'null' => true, 'comment' => '申请类型(1退货退款,2仅退款)']) - ->addColumn('code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '售后单号']) - ->addColumn('order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']) - ->addColumn('reason', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '退款原因']) - ->addColumn('number', 'biginteger', ['limit' => 20, 'default' => 1, 'null' => true, 'comment' => '退货数量']) - ->addColumn('amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '申请金额']) - ->addColumn('payment_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '退款支付']) - ->addColumn('balance_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '退款余额']) - ->addColumn('integral_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '退款积分']) - ->addColumn('payment_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '退款单号']) - ->addColumn('balance_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '退回单号']) - ->addColumn('integral_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '退回单号']) - ->addColumn('phone', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '联系电话']) - ->addColumn('images', 'text', ['default' => NULL, 'null' => true, 'comment' => '申请图片']) - ->addColumn('content', 'text', ['default' => NULL, 'null' => true, 'comment' => '申请说明']) - ->addColumn('remark', 'string', ['limit' => 180, 'default' => NULL, 'null' => true, 'comment' => '操作描述']) - ->addColumn('express_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递单号']) - ->addColumn('express_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递公司']) - ->addColumn('express_name', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '快递名称']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '流程状态(0已取消,1预订单,2待审核,3待退货,4已退货,5待退款,6已退款,7已完成)']) - ->addColumn('status_at', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '状态变更时间']) - ->addColumn('status_ds', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '状态变更描述']) - ->addColumn('admin_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '后台用户']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'i3c826a8cd_unid']) - ->addIndex('type', ['name' => 'i3c826a8cd_type']) - ->addIndex('code', ['name' => 'i3c826a8cd_code']) - ->addIndex('ssid', ['name' => 'i3c826a8cd_ssid']) - ->addIndex('status', ['name' => 'i3c826a8cd_status']) - ->addIndex('order_no', ['name' => 'i3c826a8cd_order_no']) - ->addIndex('create_time', ['name' => 'i3c826a8cd_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['type', 'biginteger', ['limit' => 20, 'default' => 1, 'null' => true, 'comment' => '申请类型(1退货退款,2仅退款)']], + ['code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '售后单号']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']], + ['reason', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '退款原因']], + ['number', 'biginteger', ['limit' => 20, 'default' => 1, 'null' => true, 'comment' => '退货数量']], + ['amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '申请金额']], + ['payment_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '退款支付']], + ['balance_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '退款余额']], + ['integral_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '退款积分']], + ['payment_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '退款单号']], + ['balance_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '退回单号']], + ['integral_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '退回单号']], + ['phone', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '联系电话']], + ['images', 'text', ['default' => NULL, 'null' => true, 'comment' => '申请图片']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '申请说明']], + ['remark', 'string', ['limit' => 180, 'default' => NULL, 'null' => true, 'comment' => '操作描述']], + ['express_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递单号']], + ['express_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递公司']], + ['express_name', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '快递名称']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '流程状态(0已取消,1预订单,2待审核,3待退货,4已退货,5待退款,6已退款,7已完成)']], + ['status_at', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '状态变更时间']], + ['status_ds', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '状态变更描述']], + ['admin_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '后台用户']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'type', 'code', 'ssid', 'status', 'order_no', 'create_time', + ]); } /** @@ -1111,54 +846,42 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_order_sender() { - - // 当前数据表 - $table = 'plugin_wemall_order_sender'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_order_sender', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-配送', - ]) - ->addColumn('ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商城用户编号']) - ->addColumn('order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商城订单单号']) - ->addColumn('address_id', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '配送地址编号']) - ->addColumn('user_idcode', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '收货人证件号码']) - ->addColumn('user_idimg1', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '收货人证件正面']) - ->addColumn('user_idimg2', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '收货人证件反面']) - ->addColumn('user_name', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '收货人联系名称']) - ->addColumn('user_phone', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '收货人联系手机']) - ->addColumn('region_prov', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '配送地址的省份']) - ->addColumn('region_city', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '配送地址的城市']) - ->addColumn('region_area', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '配送地址的区域']) - ->addColumn('region_addr', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '配送的详细地址']) - ->addColumn('delivery_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '配送模板编号']) - ->addColumn('delivery_count', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '快递计费基数']) - ->addColumn('delivery_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '配送计算金额']) - ->addColumn('delivery_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '配送计算描述']) - ->addColumn('express_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递发送时间']) - ->addColumn('express_code', 'string', ['limit' => 80, 'default' => '', 'null' => true, 'comment' => '快递运送单号']) - ->addColumn('express_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '快递发送备注']) - ->addColumn('company_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递公司编码']) - ->addColumn('company_name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '快递公司名称']) - ->addColumn('extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '原始数据']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '发货状态(1待发货,2已发货,3已收货)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'if6f961fc1_unid']) - ->addIndex('ssid', ['name' => 'if6f961fc1_ssid']) - ->addIndex('status', ['name' => 'if6f961fc1_status']) - ->addIndex('deleted', ['name' => 'if6f961fc1_deleted']) - ->addIndex('order_no', ['name' => 'if6f961fc1_order_no']) - ->addIndex('create_time', ['name' => 'if6f961fc1_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商城用户编号']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商城订单单号']], + ['address_id', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '配送地址编号']], + ['user_idcode', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '收货人证件号码']], + ['user_idimg1', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '收货人证件正面']], + ['user_idimg2', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '收货人证件反面']], + ['user_name', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '收货人联系名称']], + ['user_phone', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '收货人联系手机']], + ['region_prov', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '配送地址的省份']], + ['region_city', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '配送地址的城市']], + ['region_area', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '配送地址的区域']], + ['region_addr', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '配送的详细地址']], + ['delivery_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '配送模板编号']], + ['delivery_count', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '快递计费基数']], + ['delivery_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '配送计算金额']], + ['delivery_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '配送计算描述']], + ['express_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递发送时间']], + ['express_code', 'string', ['limit' => 80, 'default' => '', 'null' => true, 'comment' => '快递运送单号']], + ['express_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '快递发送备注']], + ['company_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递公司编码']], + ['company_name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '快递公司名称']], + ['extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '原始数据']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '发货状态(1待发货,2已发货,3已收货)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'ssid', 'status', 'deleted', 'order_no', 'create_time', + ]); } /** @@ -1169,30 +892,21 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_user_action_collect() { - - // 当前数据表 - $table = 'plugin_wemall_user_action_collect'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_action_collect', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-收藏', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']) - ->addColumn('gcode', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品编号']) - ->addColumn('times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '记录次数']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'i79fcacf4f_unid']) - ->addIndex('sort', ['name' => 'i79fcacf4f_sort']) - ->addIndex('gcode', ['name' => 'i79fcacf4f_gcode']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['gcode', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '记录次数']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'sort', 'gcode', + ]); } /** @@ -1203,43 +917,28 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_user_action_comment() { - - // 当前数据表 - $table = 'plugin_wemall_user_action_comment'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_action_comment', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-评论', - ]) - ->addColumn('ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']) - ->addColumn('code', 'string', ['limit' => 32, 'default' => NULL, 'null' => true, 'comment' => '评论编号']) - ->addColumn('gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']) - ->addColumn('ghash', 'string', ['limit' => 32, 'default' => NULL, 'null' => true, 'comment' => '商品哈希']) - ->addColumn('order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']) - ->addColumn('rate', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '5.00', 'null' => true, 'comment' => '评论分数']) - ->addColumn('content', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '评论内容']) - ->addColumn('images', 'text', ['default' => NULL, 'null' => true, 'comment' => '评论图片']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '评论状态(0隐藏,1显示)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'ie6e792cc7_unid']) - ->addIndex('code', ['name' => 'ie6e792cc7_code']) - ->addIndex('ssid', ['name' => 'ie6e792cc7_ssid']) - ->addIndex('ghash', ['name' => 'ie6e792cc7_ghash']) - ->addIndex('gcode', ['name' => 'ie6e792cc7_gcode']) - ->addIndex('status', ['name' => 'ie6e792cc7_status']) - ->addIndex('deleted', ['name' => 'ie6e792cc7_deleted']) - ->addIndex('order_no', ['name' => 'ie6e792cc7_order_no']) - ->addIndex('create_time', ['name' => 'ie6e792cc7_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['code', 'string', ['limit' => 32, 'default' => NULL, 'null' => true, 'comment' => '评论编号']], + ['gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['ghash', 'string', ['limit' => 32, 'default' => NULL, 'null' => true, 'comment' => '商品哈希']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']], + ['rate', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '5.00', 'null' => true, 'comment' => '评论分数']], + ['content', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '评论内容']], + ['images', 'text', ['default' => NULL, 'null' => true, 'comment' => '评论图片']], + ['status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '评论状态(0隐藏,1显示)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'code', 'ssid', 'ghash', 'gcode', 'status', 'deleted', 'order_no', 'create_time', + ]); } /** @@ -1250,32 +949,22 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_user_action_history() { - - // 当前数据表 - $table = 'plugin_wemall_user_action_history'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_action_history', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-足迹', - ]) - ->addColumn('ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']) - ->addColumn('gcode', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品编号']) - ->addColumn('times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '记录次数']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'i9bce34c4f_unid']) - ->addIndex('sort', ['name' => 'i9bce34c4f_sort']) - ->addIndex('ssid', ['name' => 'i9bce34c4f_ssid']) - ->addIndex('gcode', ['name' => 'i9bce34c4f_gcode']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['gcode', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '记录次数']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'sort', 'ssid', 'gcode', + ]); } /** @@ -1286,30 +975,21 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_user_action_search() { - - // 当前数据表 - $table = 'plugin_wemall_user_action_search'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_action_search', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-搜索', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']) - ->addColumn('keys', 'string', ['limit' => 99, 'default' => '', 'null' => true, 'comment' => '关键词']) - ->addColumn('times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '搜索次数']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('keys', ['name' => 'i03c8b2b46_keys']) - ->addIndex('unid', ['name' => 'i03c8b2b46_unid']) - ->addIndex('sort', ['name' => 'i03c8b2b46_sort']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['keys', 'string', ['limit' => 99, 'default' => '', 'null' => true, 'comment' => '关键词']], + ['times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '搜索次数']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'keys', 'unid', 'sort', + ]); } /** @@ -1320,36 +1000,25 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_user_checkin() { - - // 当前数据表 - $table = 'plugin_wemall_user_checkin'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_checkin', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '业务-活动-签到', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户UNID']) - ->addColumn('times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '连续天数']) - ->addColumn('timed', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '奖励天数']) - ->addColumn('date', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '签到日期']) - ->addColumn('balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '赠送余额']) - ->addColumn('integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '赠送积分']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '生效状态(0未生效,1已生效)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删除,1已删除)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'i0faf876c0_unid']) - ->addIndex('date', ['name' => 'i0faf876c0_date']) - ->addIndex('status', ['name' => 'i0faf876c0_status']) - ->addIndex('deleted', ['name' => 'i0faf876c0_deleted']) - ->addIndex('create_time', ['name' => 'i0faf876c0_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户UNID']], + ['times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '连续天数']], + ['timed', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '奖励天数']], + ['date', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '签到日期']], + ['balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '赠送余额']], + ['integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '赠送积分']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '生效状态(0未生效,1已生效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删除,1已删除)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'date', 'status', 'deleted', 'create_time', + ]); } /** @@ -1360,45 +1029,30 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_user_coupon() { - - // 当前数据表 - $table = 'plugin_wemall_user_coupon'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_coupon', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-卡券', - ]) - ->addColumn('type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '卡券类型']) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户UNID']) - ->addColumn('coid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '配置编号']) - ->addColumn('code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '卡券编号']) - ->addColumn('used', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '使用状态']) - ->addColumn('used_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '使用时间']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '生效状态(0未生效,1待使用,2已使用,3已过期)']) - ->addColumn('status_desc', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '状态描述']) - ->addColumn('status_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '修改时间']) - ->addColumn('expire', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '有效时间']) - ->addColumn('expire_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '有效日期']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删除,1已删除)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addColumn('confirm_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '到账时间']) - ->addIndex('code', ['name' => 'ic31512dc2_code']) - ->addIndex('unid', ['name' => 'ic31512dc2_unid']) - ->addIndex('coid', ['name' => 'ic31512dc2_coid']) - ->addIndex('used', ['name' => 'ic31512dc2_used']) - ->addIndex('status', ['name' => 'ic31512dc2_status']) - ->addIndex('expire', ['name' => 'ic31512dc2_expire']) - ->addIndex('deleted', ['name' => 'ic31512dc2_deleted']) - ->addIndex('create_time', ['name' => 'ic31512dc2_create_time']) - ->addIndex('confirm_time', ['name' => 'ic31512dc2_confirm_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '卡券类型']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户UNID']], + ['coid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '配置编号']], + ['code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '卡券编号']], + ['used', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '使用状态']], + ['used_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '使用时间']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '生效状态(0未生效,1待使用,2已使用,3已过期)']], + ['status_desc', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '状态描述']], + ['status_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '修改时间']], + ['expire', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '有效时间']], + ['expire_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '有效日期']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删除,1已删除)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ['confirm_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '到账时间']], + ], [ + 'code', 'unid', 'coid', 'used', 'status', 'expire', 'deleted', 'create_time', 'confirm_time', + ]); } /** @@ -1409,47 +1063,32 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_user_create() { - - // 当前数据表 - $table = 'plugin_wemall_user_create'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_create', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-创建', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => false, 'comment' => '关联用户']) - ->addColumn('name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '用户姓名']) - ->addColumn('phone', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '手机号码']) - ->addColumn('headimg', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '用户头像']) - ->addColumn('password', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '初始密码']) - ->addColumn('rebate_total', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '累计返利']) - ->addColumn('rebate_total_code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '记录编号']) - ->addColumn('rebate_total_desc', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '记录描述']) - ->addColumn('rebate_usable', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '可提返利']) - ->addColumn('rebate_usable_code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '记录编号']) - ->addColumn('rebate_usable_desc', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '记录描述']) - ->addColumn('agent_entry', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '代理权限']) - ->addColumn('agent_phone', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '上级手机']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '记录状态(0无效,1有效)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('name', ['name' => 'i55481d44e_name']) - ->addIndex('unid', ['name' => 'i55481d44e_unid']) - ->addIndex('phone', ['name' => 'i55481d44e_phone']) - ->addIndex('status', ['name' => 'i55481d44e_status']) - ->addIndex('deleted', ['name' => 'i55481d44e_deleted']) - ->addIndex('create_time', ['name' => 'i55481d44e_create_time']) - ->addIndex('agent_entry', ['name' => 'i55481d44e_agent_entry']) - ->addIndex('agent_phone', ['name' => 'i55481d44e_agent_phone']) - ->addIndex('rebate_total', ['name' => 'i55481d44e_rebate_total']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => false, 'comment' => '关联用户']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '用户姓名']], + ['phone', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '手机号码']], + ['headimg', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '用户头像']], + ['password', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '初始密码']], + ['rebate_total', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '累计返利']], + ['rebate_total_code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '记录编号']], + ['rebate_total_desc', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '记录描述']], + ['rebate_usable', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '可提返利']], + ['rebate_usable_code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '记录编号']], + ['rebate_usable_desc', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '记录描述']], + ['agent_entry', 'tinyinteger', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '代理权限']], + ['agent_phone', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '上级手机']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '记录状态(0无效,1有效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'name', 'unid', 'phone', 'status', 'deleted', 'create_time', 'agent_entry', 'agent_phone', 'rebate_total', + ]); } /** @@ -1460,50 +1099,32 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_user_rebate() { - - // 当前数据表 - $table = 'plugin_wemall_user_rebate'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_rebate', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-返利', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户UNID']) - ->addColumn('layer', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上级层级']) - ->addColumn('code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '奖励编号']) - ->addColumn('hash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '维一编号']) - ->addColumn('date', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '奖励日期']) - ->addColumn('type', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '奖励类型']) - ->addColumn('name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '奖励名称']) - ->addColumn('amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励数量']) - ->addColumn('order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']) - ->addColumn('order_unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '订单用户']) - ->addColumn('order_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '订单金额']) - ->addColumn('remark', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '奖励描述']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '生效状态(0未生效,1已生效)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删除,1已删除)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addColumn('confirm_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '到账时间']) - ->addIndex('type', ['name' => 'i5f9c1d4b3_type']) - ->addIndex('date', ['name' => 'i5f9c1d4b3_date']) - ->addIndex('code', ['name' => 'i5f9c1d4b3_code']) - ->addIndex('name', ['name' => 'i5f9c1d4b3_name']) - ->addIndex('unid', ['name' => 'i5f9c1d4b3_unid']) - ->addIndex('hash', ['name' => 'i5f9c1d4b3_hash']) - ->addIndex('status', ['name' => 'i5f9c1d4b3_status']) - ->addIndex('deleted', ['name' => 'i5f9c1d4b3_deleted']) - ->addIndex('order_no', ['name' => 'i5f9c1d4b3_order_no']) - ->addIndex('order_unid', ['name' => 'i5f9c1d4b3_order_unid']) - ->addIndex('create_time', ['name' => 'i5f9c1d4b3_create_time']) - ->addIndex('confirm_time', ['name' => 'i5f9c1d4b3_confirm_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户UNID']], + ['layer', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上级层级']], + ['code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '奖励编号']], + ['hash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '维一编号']], + ['date', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '奖励日期']], + ['type', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '奖励类型']], + ['name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '奖励名称']], + ['amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励数量']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']], + ['order_unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '订单用户']], + ['order_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '订单金额']], + ['remark', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '奖励描述']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '生效状态(0未生效,1已生效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删除,1已删除)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ['confirm_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '到账时间']], + ], [ + 'type', 'date', 'code', 'name', 'unid', 'hash', 'status', 'deleted', 'order_no', 'order_unid', 'create_time', 'confirm_time', + ]); } /** @@ -1514,37 +1135,26 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_user_recharge() { - - // 当前数据表 - $table = 'plugin_wemall_user_recharge'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_recharge', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-充值', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '账号编号']) - ->addColumn('code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '操作编号']) - ->addColumn('name', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '操作名称']) - ->addColumn('remark', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '操作备注']) - ->addColumn('amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '操作金额']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删除,1已删除)']) - ->addColumn('create_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '系统用户']) - ->addColumn('deleted_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '系统用户']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('deleted_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '删除时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'id6918c8c5_unid']) - ->addIndex('code', ['name' => 'id6918c8c5_code']) - ->addIndex('deleted', ['name' => 'id6918c8c5_deleted']) - ->addIndex('create_time', ['name' => 'id6918c8c5_create_time']) - ->addIndex('deleted_time', ['name' => 'id6918c8c5_deleted_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '账号编号']], + ['code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '操作编号']], + ['name', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '操作名称']], + ['remark', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '操作备注']], + ['amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '操作金额']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删除,1已删除)']], + ['create_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '系统用户']], + ['deleted_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '系统用户']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['deleted_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '删除时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'code', 'deleted', 'create_time', 'deleted_time', + ]); } /** @@ -1555,51 +1165,34 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_user_relation() { - - // 当前数据表 - $table = 'plugin_wemall_user_relation'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_relation', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-关系', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '当前用户']) - ->addColumn('puids', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '绑定状态']) - ->addColumn('puid1', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上1级代理']) - ->addColumn('puid2', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上2级代理']) - ->addColumn('puid3', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上3级代理']) - ->addColumn('layer', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属层级']) - ->addColumn('path', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '关系路径']) - ->addColumn('extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '扩展数据']) - ->addColumn('entry_agent', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '推广权益(0无,1有)']) - ->addColumn('entry_member', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '入会礼包(0无,1有)']) - ->addColumn('level_code', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '会员等级']) - ->addColumn('level_name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '会员名称']) - ->addColumn('agent_uuid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '绑定用户']) - ->addColumn('agent_state', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '绑定状态']) - ->addColumn('agent_level_code', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '代理等级']) - ->addColumn('agent_level_name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '代理名称']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'i863175e04_unid']) - ->addIndex('path', ['name' => 'i863175e04_path']) - ->addIndex('puid1', ['name' => 'i863175e04_puid1']) - ->addIndex('puid2', ['name' => 'i863175e04_puid2']) - ->addIndex('puid3', ['name' => 'i863175e04_puid3']) - ->addIndex('level_code', ['name' => 'i863175e04_level_code']) - ->addIndex('agent_uuid', ['name' => 'i863175e04_agent_uuid']) - ->addIndex('create_time', ['name' => 'i863175e04_create_time']) - ->addIndex('entry_agent', ['name' => 'i863175e04_entry_agent']) - ->addIndex('entry_member', ['name' => 'i863175e04_entry_member']) - ->addIndex('agent_level_code', ['name' => 'i863175e04_agent_level_code']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '当前用户']], + ['puids', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '绑定状态']], + ['puid1', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上1级代理']], + ['puid2', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上2级代理']], + ['puid3', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上3级代理']], + ['layer', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属层级']], + ['path', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '关系路径']], + ['extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '扩展数据']], + ['entry_agent', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '推广权益(0无,1有)']], + ['entry_member', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '入会礼包(0无,1有)']], + ['level_code', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '会员等级']], + ['level_name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '会员名称']], + ['agent_uuid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '绑定用户']], + ['agent_state', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '绑定状态']], + ['agent_level_code', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '代理等级']], + ['agent_level_name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '代理名称']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'path', 'puid1', 'puid2', 'puid3', 'level_code', 'agent_uuid', 'create_time', 'entry_agent', 'entry_member', 'agent_level_code', + ]); } /** @@ -1610,58 +1203,43 @@ class InstallWemall extends Migrator */ private function _create_plugin_wemall_user_transfer() { - - // 当前数据表 - $table = 'plugin_wemall_user_transfer'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_transfer', [ 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-提现', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户UNID']) - ->addColumn('type', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '提现方式']) - ->addColumn('date', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '提现日期']) - ->addColumn('code', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '提现单号']) - ->addColumn('appid', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '公众号APPID']) - ->addColumn('openid', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '公众号OPENID']) - ->addColumn('username', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '公众号真实姓名']) - ->addColumn('charge_rate', 'decimal', ['precision' => 20, 'scale' => 4, 'default' => '0.0000', 'null' => true, 'comment' => '提现手续费比例']) - ->addColumn('charge_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '提现手续费金额']) - ->addColumn('amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '提现转账金额']) - ->addColumn('qrcode', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '收款码图片地址']) - ->addColumn('bank_wseq', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '微信银行编号']) - ->addColumn('bank_name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '开户银行名称']) - ->addColumn('bank_bran', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '开户分行名称']) - ->addColumn('bank_user', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '开户账号姓名']) - ->addColumn('bank_code', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '开户银行卡号']) - ->addColumn('alipay_user', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '支付宝姓名']) - ->addColumn('alipay_code', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '支付宝账号']) - ->addColumn('remark', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '提现描述']) - ->addColumn('trade_no', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '交易单号']) - ->addColumn('trade_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '打款时间']) - ->addColumn('change_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '处理时间']) - ->addColumn('change_desc', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '处理描述']) - ->addColumn('audit_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '审核时间']) - ->addColumn('audit_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '审核状态']) - ->addColumn('audit_remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '审核描述']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '提现状态(0失败,1待审核,2已审核,3打款中,4已打款,5已收款)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('code', ['name' => 'i574337aba_code']) - ->addIndex('unid', ['name' => 'i574337aba_unid']) - ->addIndex('date', ['name' => 'i574337aba_date']) - ->addIndex('type', ['name' => 'i574337aba_type']) - ->addIndex('appid', ['name' => 'i574337aba_appid']) - ->addIndex('openid', ['name' => 'i574337aba_openid']) - ->addIndex('status', ['name' => 'i574337aba_status']) - ->addIndex('create_time', ['name' => 'i574337aba_create_time']) - ->addIndex('audit_status', ['name' => 'i574337aba_audit_status']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户UNID']], + ['type', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '提现方式']], + ['date', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '提现日期']], + ['code', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '提现单号']], + ['appid', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '公众号APPID']], + ['openid', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '公众号OPENID']], + ['username', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '公众号真实姓名']], + ['charge_rate', 'decimal', ['precision' => 20, 'scale' => 4, 'default' => '0.0000', 'null' => true, 'comment' => '提现手续费比例']], + ['charge_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '提现手续费金额']], + ['amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '提现转账金额']], + ['qrcode', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '收款码图片地址']], + ['bank_wseq', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '微信银行编号']], + ['bank_name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '开户银行名称']], + ['bank_bran', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '开户分行名称']], + ['bank_user', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '开户账号姓名']], + ['bank_code', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '开户银行卡号']], + ['alipay_user', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '支付宝姓名']], + ['alipay_code', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '支付宝账号']], + ['remark', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '提现描述']], + ['trade_no', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '交易单号']], + ['trade_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '打款时间']], + ['change_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '处理时间']], + ['change_desc', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '处理描述']], + ['audit_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '审核时间']], + ['audit_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '审核状态']], + ['audit_remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '审核描述']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '提现状态(0失败,1待审核,2已审核,3打款中,4已打款,5已收款)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'unid', 'date', 'type', 'appid', 'openid', 'status', 'create_time', 'audit_status', + ]); } } diff --git a/plugin/think-plugs-wemall/stc/database/20230404000002_install_wemall20231021.php b/plugin/think-plugs-wemall/stc/database/20230404000002_install_wemall20231021.php deleted file mode 100644 index c6ae513ce..000000000 --- a/plugin/think-plugs-wemall/stc/database/20230404000002_install_wemall20231021.php +++ /dev/null @@ -1,254 +0,0 @@ -table('plugin_wemall_config_level'); - $table->hasColumn('cardbg') || $table->addColumn('cardbg', 'string', [ - 'limit' => 500, 'default' => '', 'null' => true, 'after' => 'cover', 'comment' => '会员等级卡片' - ])->update(); - - // 检查并更新商品规格表 - $table = $this->table('plugin_wemall_goods_item'); - $table->hasColumn('price_cost') || $table->addColumn('price_cost', 'decimal', [ - 'precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'after' => 'stock_total', 'comment' => '成本价格' - ])->update(); - - // 检查并更新订单主表 - $table = $this->table('plugin_wemall_order'); - $table->hasColumn('amount_cost') || $table->addColumn('amount_cost', 'decimal', [ - 'precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'after' => 'order_ps', 'comment' => '商品成本' - ])->addColumn('amount_profit', 'decimal', [ - 'precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'after' => 'amount_reduct', 'comment' => '销售利润' - ])->update(); - - // 检查并更新订单商品 - $table = $this->table('plugin_wemall_order_item'); - $table->hasColumn('amount_cost') || $table->addColumn('amount_cost', 'decimal', [ - 'precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'after' => 'stock_sales', 'comment' => '商品成本单价' - ])->addColumn('total_price_cost', 'decimal', [ - 'precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'after' => 'price_selling', 'comment' => '商品成本总价' - ])->update(); - - // 创建新数据库 - $this->_create_plugin_wemall_config_notify(); - $this->_create_plugin_wemall_config_poster(); - $this->_create_plugin_wemall_user_action_collect(); - $this->_create_plugin_wemall_user_action_history(); - $this->_create_plugin_wemall_user_action_search(); - } - - /** - * 创建数据对象 - * @class PluginWemallConfigPoster - * @table plugin_wemall_config_poster - * @return void - */ - private function _create_plugin_wemall_config_poster() - { - - // 当前数据表 - $table = 'plugin_wemall_config_poster'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ - 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-海报', - ]) - ->addColumn('code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '推广编号']) - ->addColumn('name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '推广标题']) - ->addColumn('levels', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '会员等级']) - ->addColumn('devices', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '接口通道']) - ->addColumn('image', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '推广图片']) - ->addColumn('content', 'text', ['default' => NULL, 'null' => true, 'comment' => '二维位置']) - ->addColumn('remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '推广描述']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('code', ['name' => 'ib84148924_code']) - ->addIndex('sort', ['name' => 'ib84148924_sort']) - ->addIndex('name', ['name' => 'ib84148924_name']) - ->addIndex('status', ['name' => 'ib84148924_status']) - ->addIndex('deleted', ['name' => 'ib84148924_deleted']) - ->addIndex('create_time', ['name' => 'ib84148924_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); - } - - /** - * 创建数据对象 - * @class PluginWemallUserActionCollect - * @table plugin_wemall_user_action_collect - * @return void - */ - private function _create_plugin_wemall_user_action_collect() - { - - // 当前数据表 - $table = 'plugin_wemall_user_action_collect'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ - 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-收藏', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']) - ->addColumn('gcode', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品编号']) - ->addColumn('times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '记录次数']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'i79fcacf4f_unid']) - ->addIndex('sort', ['name' => 'i79fcacf4f_sort']) - ->addIndex('gcode', ['name' => 'i79fcacf4f_gcode']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); - } - - /** - * 创建数据对象 - * @class PluginWemallUserActionHistory - * @table plugin_wemall_user_action_history - * @return void - */ - private function _create_plugin_wemall_user_action_history() - { - - // 当前数据表 - $table = 'plugin_wemall_user_action_history'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ - 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-足迹', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']) - ->addColumn('gcode', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品编号']) - ->addColumn('times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '记录次数']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('unid', ['name' => 'i9bce34c4f_unid']) - ->addIndex('sort', ['name' => 'i9bce34c4f_sort']) - ->addIndex('gcode', ['name' => 'i9bce34c4f_gcode']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); - } - - /** - * 创建数据对象 - * @class PluginWemallUserActionSearch - * @table plugin_wemall_user_action_search - * @return void - */ - private function _create_plugin_wemall_user_action_search() - { - - // 当前数据表 - $table = 'plugin_wemall_user_action_search'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ - 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-搜索', - ]) - ->addColumn('unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']) - ->addColumn('keys', 'string', ['limit' => 99, 'default' => '', 'null' => true, 'comment' => '关键词']) - ->addColumn('times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '搜索次数']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('keys', ['name' => 'i03c8b2b46_keys']) - ->addIndex('unid', ['name' => 'i03c8b2b46_unid']) - ->addIndex('sort', ['name' => 'i03c8b2b46_sort']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); - } - - /** - * 创建数据对象 - * @class PluginWemallConfigNotify - * @table plugin_wemall_config_notify - * @return void - */ - private function _create_plugin_wemall_config_notify() - { - - // 当前数据表 - $table = 'plugin_wemall_config_notify'; - - // 存在则跳过 - if ($this->hasTable($table)) return; - - // 创建数据表 - $this->table($table, [ - 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-通知', - ]) - ->addColumn('code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '通知编号']) - ->addColumn('name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '通知标题']) - ->addColumn('cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '通知图片']) - ->addColumn('levels', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '会员等级']) - ->addColumn('content', 'text', ['default' => NULL, 'null' => true, 'comment' => '通知内容']) - ->addColumn('remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '通知描述']) - ->addColumn('num_read', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '阅读次数']) - ->addColumn('tips', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => 'TIPS显示']) - ->addColumn('sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']) - ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']) - ->addColumn('deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']) - ->addColumn('create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']) - ->addColumn('update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']) - ->addIndex('code', ['name' => 'i0614c3468_code']) - ->addIndex('sort', ['name' => 'i0614c3468_sort']) - ->addIndex('name', ['name' => 'i0614c3468_name']) - ->addIndex('tips', ['name' => 'i0614c3468_tips']) - ->addIndex('status', ['name' => 'i0614c3468_status']) - ->addIndex('deleted', ['name' => 'i0614c3468_deleted']) - ->addIndex('create_time', ['name' => 'i0614c3468_create_time']) - ->create(); - - // 修改主键长度 - $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]); - } -} diff --git a/plugin/think-plugs-wemall/stc/database/20241016000001_install_wemall20241016.php b/plugin/think-plugs-wemall/stc/database/20241016000001_install_wemall20241016.php new file mode 100644 index 000000000..609589414 --- /dev/null +++ b/plugin/think-plugs-wemall/stc/database/20241016000001_install_wemall20241016.php @@ -0,0 +1,1278 @@ +_create_plugin_wemall_config_agent(); + $this->_create_plugin_wemall_config_coupon(); + $this->_create_plugin_wemall_config_discount(); + $this->_create_plugin_wemall_config_level(); + $this->_create_plugin_wemall_config_notify(); + $this->_create_plugin_wemall_config_poster(); + $this->_create_plugin_wemall_config_rebate(); + $this->_create_plugin_wemall_express_company(); + $this->_create_plugin_wemall_express_template(); + $this->_create_plugin_wemall_goods(); + $this->_create_plugin_wemall_goods_cate(); + $this->_create_plugin_wemall_goods_item(); + $this->_create_plugin_wemall_goods_mark(); + $this->_create_plugin_wemall_goods_stock(); + $this->_create_plugin_wemall_help_feedback(); + $this->_create_plugin_wemall_help_problem(); + $this->_create_plugin_wemall_help_question(); + $this->_create_plugin_wemall_help_question_x(); + $this->_create_plugin_wemall_order(); + $this->_create_plugin_wemall_order_cart(); + $this->_create_plugin_wemall_order_item(); + $this->_create_plugin_wemall_order_refund(); + $this->_create_plugin_wemall_order_sender(); + $this->_create_plugin_wemall_user_action_collect(); + $this->_create_plugin_wemall_user_action_comment(); + $this->_create_plugin_wemall_user_action_history(); + $this->_create_plugin_wemall_user_action_search(); + $this->_create_plugin_wemall_user_checkin(); + $this->_create_plugin_wemall_user_coupon(); + $this->_create_plugin_wemall_user_create(); + $this->_create_plugin_wemall_user_rebate(); + $this->_create_plugin_wemall_user_recharge(); + $this->_create_plugin_wemall_user_relation(); + $this->_create_plugin_wemall_user_transfer(); + } + + /** + * 创建数据对象 + * @class PluginWemallConfigAgent + * @table plugin_wemall_config_agent + * @return void + */ + private function _create_plugin_wemall_config_agent() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_agent', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-等级', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '级别名称']], + ['cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '等级图标']], + ['cardbg', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '等级卡片']], + ['number', 'integer', ['limit' => 2, 'default' => 0, 'null' => true, 'comment' => '级别序号']], + ['upgrade_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '升级规则(0单个,1同时)']], + ['extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '升级规则']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '级别描述']], + ['utime', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '更新时间']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '等级状态(1使用,0禁用)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'utime', 'status', 'number', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallConfigCoupon + * @table plugin_wemall_config_coupon + * @return void + */ + private function _create_plugin_wemall_config_coupon() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_coupon', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-卡券', + ], true); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['type', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '类型(0通用券,1商品券)']], + ['name', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '优惠名称']], + ['cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '封面图标']], + ['extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '扩展数据']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '内容描述']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '系统备注']], + ['amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '抵扣金额']], + ['limit_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '金额门槛(0不限制)']], + ['limit_levels', 'string', ['limit' => 180, 'default' => '-', 'null' => true, 'comment' => '授权等级']], + ['limit_times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '限领数量(0不限制)']], + ['expire_days', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '有效天数']], + ['total_stock', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '库存数量']], + ['total_sales', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '发放数量']], + ['total_used', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '使用数量']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '卡券状态(0禁用,1使用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'sort', 'type', 'status', 'deleted', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallConfigDiscount + * @table plugin_wemall_config_discount + * @return void + */ + private function _create_plugin_wemall_config_discount() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_discount', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-折扣', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['name', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '方案名称']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '方案描述']], + ['items', 'text', ['default' => NULL, 'null' => true, 'comment' => '方案规则']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '方案状态(0禁用,1使用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'sort', 'status', 'deleted', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallConfigLevel + * @table plugin_wemall_config_level + * @return void + */ + private function _create_plugin_wemall_config_level() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_level', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-等级', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '级别名称']], + ['cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '等级图标']], + ['cardbg', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '等级卡片']], + ['number', 'integer', ['limit' => 2, 'default' => 0, 'null' => true, 'comment' => '级别序号']], + ['upgrade_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '升级规则(0单个,1同时)']], + ['upgrade_team', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '团队人数统计(0不计,1累计)']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '用户级别描述']], + ['extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '配置规则']], + ['utime', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '更新时间']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '等级状态(1使用,0禁用)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'utime', 'status', 'number', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallConfigNotify + * @table plugin_wemall_config_notify + * @return void + */ + private function _create_plugin_wemall_config_notify() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_notify', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-通知', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '通知编号']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '通知标题']], + ['cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '通知图片']], + ['levels', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '用户等级']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '通知内容']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '通知描述']], + ['num_read', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '阅读次数']], + ['tips', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => 'TIPS显示']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'sort', 'name', 'tips', 'status', 'deleted', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallConfigPoster + * @table plugin_wemall_config_poster + * @return void + */ + private function _create_plugin_wemall_config_poster() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_poster', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-海报', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '推广编号']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '推广标题']], + ['levels', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '用户等级']], + ['devices', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '接口通道']], + ['image', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '推广图片']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '二维位置']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '推广描述']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'sort', 'name', 'status', 'deleted', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallConfigRebate + * @table plugin_wemall_config_rebate + * @return void + */ + private function _create_plugin_wemall_config_rebate() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_config_rebate', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-配置-返利', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['type', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '奖励类型']], + ['code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '配置编号']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '配置名称']], + ['path', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '等级关系']], + ['stype', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '结算类型(0支付结算,1收货结算)']], + ['p0_level', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '会员等级']], + ['p1_level', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '上1级等级']], + ['p2_level', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '上2级等级']], + ['p3_level', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '上3级等级']], + ['p0_reward_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '会员计算类型(0固定金额,1交易比例,2利润比例)']], + ['p0_reward_number', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '会员计算系数']], + ['p1_reward_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '上1级计算类型(0固定金额,1交易比例,2利润比例)']], + ['p1_reward_number', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '上1级计算系数']], + ['p2_reward_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '上2级计算类型(0固定金额,1交易比例,2利润比例)']], + ['p2_reward_number', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '上2级计算系数']], + ['p3_reward_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '上3级计算类型(0固定金额,1交易比例,2利润比例)']], + ['p3_reward_number', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '上3级计算系数']], + ['remark', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '配置描述']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'sort', 'name', 'type', 'stype', 'status', 'deleted', 'p1_level', 'p2_level', 'p3_level', 'p0_level', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallExpressCompany + * @table plugin_wemall_express_company + * @return void + */ + private function _create_plugin_wemall_express_company() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_express_company', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-快递-公司', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '公司代码']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '公司名称']], + ['remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '公司描述']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'sort', 'name', 'status', 'deleted', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallExpressTemplate + * @table plugin_wemall_express_template + * @return void + */ + private function _create_plugin_wemall_express_template() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_express_template', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-快递-模板', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '模板编号']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '模板名称']], + ['normal', 'text', ['default' => NULL, 'null' => true, 'comment' => '默认规则']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '模板规则']], + ['company', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '快递公司']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '激活状态(0无效,1有效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(1已删,0未删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'sort', 'name', 'status', 'deleted', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallGoods + * @table plugin_wemall_goods + * @return void + */ + private function _create_plugin_wemall_goods() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_goods', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-内容', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['name', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '商品名称']], + ['marks', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '商品标签']], + ['cates', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '分类编号']], + ['cover', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '商品封面']], + ['slider', 'text', ['default' => NULL, 'null' => true, 'comment' => '轮播图片']], + ['specs', 'text', ['default' => NULL, 'null' => true, 'comment' => '商品规格(JSON)']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '商品详情']], + ['remark', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '商品描述']], + ['stock_total', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品库存统计']], + ['stock_sales', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品销售统计']], + ['stock_virtual', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品虚拟销量']], + ['price_selling', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最低销售价格']], + ['price_market', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最低市场价格']], + ['allow_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大积分兑换']], + ['allow_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大余额支付']], + ['rebate_type', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '参与返利(0无需返利,1需要返利)']], + ['delivery_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '物流运费模板']], + ['limit_lowvip', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '限制购买等级(0不限制,其他限制)']], + ['limit_maxnum', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '最大购买数量(0不限制,其他限制)']], + ['level_agent', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '推广权益(0无,1有)']], + ['level_upgrade', 'biginteger', ['limit' => 20, 'default' => -1, 'null' => true, 'comment' => '购买升级等级(-1非入会,0不升级,其他升级)']], + ['discount_id', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '折扣方案编号(0无折扣,其他折扣)']], + ['num_read', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '访问阅读统计']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '列表排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '商品状态(1使用,0禁用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'sort', 'ssid', 'status', 'deleted', 'rebate_type', 'discount_id', 'create_time', 'level_agent', 'level_upgrade', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallGoodsCate + * @table plugin_wemall_goods_cate + * @return void + */ + private function _create_plugin_wemall_goods_cate() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_goods_cate', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-分类', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['pid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上级分类']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '分类名称']], + ['cover', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '分类图标']], + ['remark', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '分类描述']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '使用状态']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'pid', 'sort', 'status', 'deleted', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallGoodsItem + * @table plugin_wemall_goods_item + * @return void + */ + private function _create_plugin_wemall_goods_item() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_goods_item', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-规格', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['gsku', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品SKU']], + ['ghash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品哈希']], + ['gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['gspec', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '商品规格']], + ['gunit', 'string', ['limit' => 10, 'default' => '件', 'null' => true, 'comment' => '商品单位']], + ['gimage', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '商品图片']], + ['stock_sales', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '销售数量']], + ['stock_total', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品库存']], + ['price_cost', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '进货成本']], + ['price_selling', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '销售价格']], + ['price_market', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '市场价格']], + ['allow_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '兑换积分']], + ['allow_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '余额支付']], + ['reward_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励余额']], + ['reward_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励积分']], + ['number_virtual', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '虚拟销量']], + ['number_express', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '计件系数']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '商品状态']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'gcode', 'gspec', 'ghash', 'status', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallGoodsMark + * @table plugin_wemall_goods_mark + * @return void + */ + private function _create_plugin_wemall_goods_mark() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_goods_mark', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-标签', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '标签名称']], + ['remark', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '标签描述']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '标签状态(1使用,0禁用)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'sort', 'status', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallGoodsStock + * @table plugin_wemall_goods_stock + * @return void + */ + private function _create_plugin_wemall_goods_stock() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_goods_stock', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-商品-库存', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['batch_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '操作批量']], + ['ghash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品哈希']], + ['gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['gspec', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '商品规格']], + ['gstock', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '入库数量']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '数据状态(1使用,0禁用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'ghash', 'gcode', 'status', 'deleted', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallHelpFeedback + * @table plugin_wemall_help_feedback + * @return void + */ + private function _create_plugin_wemall_help_feedback() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_help_feedback', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-意见-反馈', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '反馈用户']], + ['phone', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '联系电话']], + ['images', 'text', ['default' => NULL, 'null' => true, 'comment' => '反馈图片']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '反馈内容']], + ['reply', 'text', ['default' => NULL, 'null' => true, 'comment' => '回复内容']], + ['reply_st', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '回复状态']], + ['reply_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '回复用户']], + ['reply_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '回复时间']], + ['sync', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '同步至常见问题状态(1已同步,0未同步)']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '展示状态(1使用,0禁用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'sort', 'unid', 'status', 'deleted', 'reply_st', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallHelpProblem + * @table plugin_wemall_help_problem + * @return void + */ + private function _create_plugin_wemall_help_problem() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_help_problem', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-常见-问题', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['fid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => false, 'comment' => '来自反馈']], + ['name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '问题标题']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '问题内容']], + ['num_er', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '未解决数']], + ['num_ok', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '已解决数']], + ['num_read', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '阅读次数']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '展示状态(1使用,0禁用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'sort', 'status', 'deleted', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallHelpQuestion + * @table plugin_wemall_help_question + * @return void + */ + private function _create_plugin_wemall_help_question() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_help_question', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-问答-内容', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '提问用户']], + ['name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '工单标题']], + ['phone', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '联系电话']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '关联订单']], + ['images', 'text', ['default' => NULL, 'null' => true, 'comment' => '工单图片']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '工单描述']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '工单状态(0取消,1新工单,2后台回复,3前台回复,4已完结)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'sort', 'name', 'unid', 'phone', 'status', 'deleted', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallHelpQuestionX + * @table plugin_wemall_help_question_x + * @return void + */ + private function _create_plugin_wemall_help_question_x() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_help_question_x', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '数据-问答-评论', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ccid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '目标编号']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '文本内容']], + ['images', 'text', ['default' => NULL, 'null' => true, 'comment' => '图片内容']], + ['reply_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '后台用户']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '记录状态(0无效,1待审核,2已审核)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'ccid', 'unid', 'status', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallOrder + * @table plugin_wemall_order + * @return void + */ + private function _create_plugin_wemall_order() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_order', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-内容', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['puid1', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上1级代理']], + ['puid2', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上2级代理']], + ['puid3', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上3级代理']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']], + ['order_ps', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '订单备注']], + ['amount_cost', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品成本']], + ['amount_real', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '实际金额']], + ['amount_total', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '订单金额']], + ['amount_goods', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品金额']], + ['amount_profit', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '销售利润']], + ['amount_reduct', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '随机减免']], + ['amount_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '余额支付']], + ['amount_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '积分抵扣']], + ['amount_payment', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '金额支付']], + ['amount_express', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '快递费用']], + ['amount_discount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '折扣后金额']], + ['coupon_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '优惠券编号']], + ['coupon_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '优惠券金额']], + ['allow_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大余额支付']], + ['allow_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大积分抵扣']], + ['ratio_integral', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '0.000000', 'null' => true, 'comment' => '积分兑换比例']], + ['number_goods', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商品数量']], + ['number_express', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '快递计数']], + ['level_agent', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '升级代理等级']], + ['level_member', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '升级会员等级']], + ['rebate_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '返利金额']], + ['reward_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励余额']], + ['reward_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励积分']], + ['payment_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '支付时间']], + ['payment_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '支付状态(0未支付,1有支付)']], + ['payment_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '实际支付']], + ['delivery_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '物流类型(0无配送,1需配送)']], + ['cancel_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '取消时间']], + ['cancel_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '取消状态']], + ['cancel_remark', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '取消描述']], + ['deleted_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '删除时间']], + ['deleted_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['deleted_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '删除描述']], + ['confirm_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '签收时间']], + ['confirm_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '签收描述']], + ['refund_code', 'string', ['limit' => 20, 'default' => NULL, 'null' => true, 'comment' => '售后单号']], + ['refund_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '售后状态(0未售后,1预订单,2待审核,3待退货,4已退货,5待退款,6已退款,7已完成)']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '流程状态(0已取消,1预订单,2待支付,3待审核,4待发货,5已发货,6已收货,7已评论)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'ssid', 'puid1', 'puid2', 'puid3', 'status', 'order_no', 'create_time', 'refund_code', 'coupon_code', 'delivery_type', 'cancel_status', 'refund_status', 'deleted_status', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallOrderCart + * @table plugin_wemall_order_cart + * @return void + */ + private function _create_plugin_wemall_order_cart() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_order_cart', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-购物车', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['ghash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '规格哈希']], + ['gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['gspec', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '商品规格']], + ['number', 'biginteger', ['limit' => 20, 'default' => 1, 'null' => true, 'comment' => '商品数量']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'ssid', 'gcode', 'gspec', 'ghash', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallOrderItem + * @table plugin_wemall_order_item + * @return void + */ + private function _create_plugin_wemall_order_item() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_order_item', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-商品', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['gsku', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品SKU']], + ['ghash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品哈希']], + ['gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['gspec', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '商品规格']], + ['gunit', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '商品单凭']], + ['gname', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '商品名称']], + ['gcover', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '商品封面']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']], + ['stock_sales', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '包含商品数量']], + ['amount_cost', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品成本单价']], + ['price_market', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品市场单价']], + ['price_selling', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品销售单价']], + ['total_price_cost', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品成本总价']], + ['total_price_market', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品市场总价']], + ['total_price_selling', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品销售总价']], + ['total_allow_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大余额支付']], + ['total_allow_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '最大兑换总分']], + ['total_reward_balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品奖励余额']], + ['total_reward_integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品奖励积分']], + ['level_code', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户等级序号']], + ['level_name', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '用户等级名称']], + ['level_agent', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '推广权益(0无,1有)']], + ['level_upgrade', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '购买升级等级(-1非入会,0不升级,其他升级)']], + ['rebate_type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '参与返利状态(0不返,1返利)']], + ['rebate_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '参与返利金额']], + ['delivery_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递邮费模板']], + ['delivery_count', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '快递计费基数']], + ['discount_id', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '优惠方案编号']], + ['discount_rate', 'decimal', ['precision' => 20, 'scale' => 6, 'default' => '100.000000', 'null' => true, 'comment' => '销售价格折扣']], + ['discount_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '商品优惠金额']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '商品状态(1使用,0禁用)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'gsku', 'ssid', 'gcode', 'gspec', 'ghash', 'status', 'deleted', 'order_no', 'rebate_type', 'discount_id', 'level_agent', 'delivery_code', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallOrderRefund + * @table plugin_wemall_order_refund + * @return void + */ + private function _create_plugin_wemall_order_refund() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_order_refund', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-售后', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['type', 'biginteger', ['limit' => 20, 'default' => 1, 'null' => true, 'comment' => '申请类型(1退货退款,2仅退款)']], + ['code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '售后单号']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']], + ['reason', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '退款原因']], + ['number', 'biginteger', ['limit' => 20, 'default' => 1, 'null' => true, 'comment' => '退货数量']], + ['amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '申请金额']], + ['payment_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '退款支付']], + ['balance_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '退款余额']], + ['integral_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '退款积分']], + ['payment_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '退款单号']], + ['balance_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '退回单号']], + ['integral_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '退回单号']], + ['phone', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '联系电话']], + ['images', 'text', ['default' => NULL, 'null' => true, 'comment' => '申请图片']], + ['content', 'text', ['default' => NULL, 'null' => true, 'comment' => '申请说明']], + ['remark', 'string', ['limit' => 180, 'default' => NULL, 'null' => true, 'comment' => '操作描述']], + ['express_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递单号']], + ['express_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递公司']], + ['express_name', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '快递名称']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '流程状态(0已取消,1预订单,2待审核,3待退货,4已退货,5待退款,6已退款,7已完成)']], + ['status_at', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '状态变更时间']], + ['status_ds', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '状态变更描述']], + ['admin_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '后台用户']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'type', 'code', 'ssid', 'status', 'order_no', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallOrderSend + * @table plugin_wemall_order_send + * @return void + */ + private function _create_plugin_wemall_order_send() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_order_send', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-配送', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商城用户编号']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商城订单单号']], + ['address_id', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '配送地址编号']], + ['user_idcode', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '收货人证件号码']], + ['user_idimg1', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '收货人证件正面']], + ['user_idimg2', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '收货人证件反面']], + ['user_name', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '收货人联系名称']], + ['user_phone', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '收货人联系手机']], + ['region_prov', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '配送地址的省份']], + ['region_city', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '配送地址的城市']], + ['region_area', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '配送地址的区域']], + ['region_addr', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '配送的详细地址']], + ['delivery_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '配送模板编号']], + ['delivery_count', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '快递计费基数']], + ['delivery_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '配送计算金额']], + ['delivery_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '配送计算描述']], + ['express_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递发送时间']], + ['express_code', 'string', ['limit' => 80, 'default' => '', 'null' => true, 'comment' => '快递运送单号']], + ['express_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '快递发送备注']], + ['company_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递公司编码']], + ['company_name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '快递公司名称']], + ['extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '原始数据']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '发货状态(1待发货,2已发货,3已收货)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'status', 'deleted', 'order_no', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallOrderSender + * @table plugin_wemall_order_sender + * @return void + */ + private function _create_plugin_wemall_order_sender() + { + // 数据表重命名 + if ($this->hasTable('plugin_wemall_order_send') && !$this->hasTable('plugin_wemall_order_sender')) { + $this->table('plugin_wemall_order_send')->rename('plugin_wemall_order_sender'); + } + + // 创建数据表对象 + $table = $this->table('plugin_wemall_order_sender', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-订单-配送', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '商城用户编号']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商城订单单号']], + ['address_id', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '配送地址编号']], + ['user_idcode', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '收货人证件号码']], + ['user_idimg1', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '收货人证件正面']], + ['user_idimg2', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '收货人证件反面']], + ['user_name', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '收货人联系名称']], + ['user_phone', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '收货人联系手机']], + ['region_prov', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '配送地址的省份']], + ['region_city', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '配送地址的城市']], + ['region_area', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '配送地址的区域']], + ['region_addr', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '配送的详细地址']], + ['delivery_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '配送模板编号']], + ['delivery_count', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '快递计费基数']], + ['delivery_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '配送计算金额']], + ['delivery_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '配送计算描述']], + ['express_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递发送时间']], + ['express_code', 'string', ['limit' => 80, 'default' => '', 'null' => true, 'comment' => '快递运送单号']], + ['express_remark', 'string', ['limit' => 255, 'default' => '', 'null' => true, 'comment' => '快递发送备注']], + ['company_code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '快递公司编码']], + ['company_name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '快递公司名称']], + ['extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '原始数据']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '发货状态(1待发货,2已发货,3已收货)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'ssid', 'status', 'deleted', 'order_no', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallUserActionCollect + * @table plugin_wemall_user_action_collect + * @return void + */ + private function _create_plugin_wemall_user_action_collect() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_action_collect', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-收藏', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['gcode', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '记录次数']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'sort', 'gcode', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallUserActionComment + * @table plugin_wemall_user_action_comment + * @return void + */ + private function _create_plugin_wemall_user_action_comment() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_action_comment', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-评论', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['code', 'string', ['limit' => 32, 'default' => NULL, 'null' => true, 'comment' => '评论编号']], + ['gcode', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['ghash', 'string', ['limit' => 32, 'default' => NULL, 'null' => true, 'comment' => '商品哈希']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']], + ['rate', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '5.00', 'null' => true, 'comment' => '评论分数']], + ['content', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '评论内容']], + ['images', 'text', ['default' => NULL, 'null' => true, 'comment' => '评论图片']], + ['status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '评论状态(0隐藏,1显示)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'code', 'ssid', 'ghash', 'gcode', 'status', 'deleted', 'order_no', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallUserActionHistory + * @table plugin_wemall_user_action_history + * @return void + */ + private function _create_plugin_wemall_user_action_history() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_action_history', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-足迹', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['ssid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属商家']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['gcode', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '商品编号']], + ['times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '记录次数']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'sort', 'ssid', 'gcode', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallUserActionSearch + * @table plugin_wemall_user_action_search + * @return void + */ + private function _create_plugin_wemall_user_action_search() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_action_search', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-搜索', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户编号']], + ['keys', 'string', ['limit' => 99, 'default' => '', 'null' => true, 'comment' => '关键词']], + ['times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '搜索次数']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'keys', 'unid', 'sort', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallUserCheckin + * @table plugin_wemall_user_checkin + * @return void + */ + private function _create_plugin_wemall_user_checkin() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_checkin', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '业务-活动-签到', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户UNID']], + ['times', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '连续天数']], + ['timed', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '奖励天数']], + ['date', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '签到日期']], + ['balance', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '赠送余额']], + ['integral', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '赠送积分']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '生效状态(0未生效,1已生效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删除,1已删除)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'date', 'status', 'deleted', 'create_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallUserCoupon + * @table plugin_wemall_user_coupon + * @return void + */ + private function _create_plugin_wemall_user_coupon() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_coupon', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-卡券', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['type', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '卡券类型']], + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户UNID']], + ['coid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '配置编号']], + ['code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '卡券编号']], + ['used', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '使用状态']], + ['used_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '使用时间']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '生效状态(0未生效,1待使用,2已使用,3已过期)']], + ['status_desc', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '状态描述']], + ['status_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '修改时间']], + ['expire', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '有效时间']], + ['expire_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '有效日期']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删除,1已删除)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ['confirm_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '到账时间']], + ], [ + 'code', 'unid', 'coid', 'used', 'status', 'expire', 'deleted', 'create_time', 'confirm_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallUserCreate + * @table plugin_wemall_user_create + * @return void + */ + private function _create_plugin_wemall_user_create() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_create', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-创建', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => false, 'comment' => '关联用户']], + ['name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '用户姓名']], + ['phone', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '手机号码']], + ['headimg', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '用户头像']], + ['password', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '初始密码']], + ['rebate_total', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '累计返利']], + ['rebate_total_code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '记录编号']], + ['rebate_total_desc', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '记录描述']], + ['rebate_usable', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '可提返利']], + ['rebate_usable_code', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '记录编号']], + ['rebate_usable_desc', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '记录描述']], + ['agent_entry', 'tinyinteger', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '代理权限']], + ['agent_phone', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '上级手机']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '记录状态(0无效,1有效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删,1已删)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'name', 'unid', 'phone', 'status', 'deleted', 'create_time', 'agent_entry', 'agent_phone', 'rebate_total', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallUserRebate + * @table plugin_wemall_user_rebate + * @return void + */ + private function _create_plugin_wemall_user_rebate() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_rebate', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-返利', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户UNID']], + ['layer', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上级层级']], + ['code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '奖励编号']], + ['hash', 'string', ['limit' => 32, 'default' => '', 'null' => true, 'comment' => '维一编号']], + ['date', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '奖励日期']], + ['type', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '奖励类型']], + ['name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '奖励名称']], + ['amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '奖励数量']], + ['order_no', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '订单单号']], + ['order_unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '订单用户']], + ['order_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '订单金额']], + ['remark', 'string', ['limit' => 50, 'default' => '', 'null' => true, 'comment' => '奖励描述']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '生效状态(0未生效,1已生效)']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删除,1已删除)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ['confirm_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '到账时间']], + ], [ + 'type', 'date', 'code', 'name', 'unid', 'hash', 'status', 'deleted', 'order_no', 'order_unid', 'create_time', 'confirm_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallUserRecharge + * @table plugin_wemall_user_recharge + * @return void + */ + private function _create_plugin_wemall_user_recharge() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_recharge', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-充值', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '账号编号']], + ['code', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '操作编号']], + ['name', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '操作名称']], + ['remark', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '操作备注']], + ['amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '操作金额']], + ['deleted', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '删除状态(0未删除,1已删除)']], + ['create_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '系统用户']], + ['deleted_by', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '系统用户']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['deleted_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '删除时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'code', 'deleted', 'create_time', 'deleted_time', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallUserRelation + * @table plugin_wemall_user_relation + * @return void + */ + private function _create_plugin_wemall_user_relation() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_relation', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-关系', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '当前用户']], + ['puids', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '绑定状态']], + ['puid1', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上1级代理']], + ['puid2', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上2级代理']], + ['puid3', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '上3级代理']], + ['layer', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '所属层级']], + ['path', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '关系路径']], + ['extra', 'text', ['default' => NULL, 'null' => true, 'comment' => '扩展数据']], + ['entry_agent', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '推广权益(0无,1有)']], + ['entry_member', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '入会礼包(0无,1有)']], + ['level_code', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '会员等级']], + ['level_name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '会员名称']], + ['agent_uuid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '绑定用户']], + ['agent_state', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '绑定状态']], + ['agent_level_code', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '代理等级']], + ['agent_level_name', 'string', ['limit' => 180, 'default' => '', 'null' => true, 'comment' => '代理名称']], + ['sort', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '排序权重']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'unid', 'path', 'puid1', 'puid2', 'puid3', 'level_code', 'agent_uuid', 'create_time', 'entry_agent', 'entry_member', 'agent_level_code', + ], true); + } + + /** + * 创建数据对象 + * @class PluginWemallUserTransfer + * @table plugin_wemall_user_transfer + * @return void + */ + private function _create_plugin_wemall_user_transfer() + { + // 创建数据表对象 + $table = $this->table('plugin_wemall_user_transfer', [ + 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '商城-用户-提现', + ]); + // 创建或更新数据表 + PhinxExtend::upgrade($table, [ + ['unid', 'biginteger', ['limit' => 20, 'default' => 0, 'null' => true, 'comment' => '用户UNID']], + ['type', 'string', ['limit' => 30, 'default' => '', 'null' => true, 'comment' => '提现方式']], + ['date', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '提现日期']], + ['code', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '提现单号']], + ['appid', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '公众号APPID']], + ['openid', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '公众号OPENID']], + ['username', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '公众号真实姓名']], + ['charge_rate', 'decimal', ['precision' => 20, 'scale' => 4, 'default' => '0.0000', 'null' => true, 'comment' => '提现手续费比例']], + ['charge_amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '提现手续费金额']], + ['amount', 'decimal', ['precision' => 20, 'scale' => 2, 'default' => '0.00', 'null' => true, 'comment' => '提现转账金额']], + ['qrcode', 'string', ['limit' => 999, 'default' => '', 'null' => true, 'comment' => '收款码图片地址']], + ['bank_wseq', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '微信银行编号']], + ['bank_name', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '开户银行名称']], + ['bank_bran', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '开户分行名称']], + ['bank_user', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '开户账号姓名']], + ['bank_code', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '开户银行卡号']], + ['alipay_user', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '支付宝姓名']], + ['alipay_code', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '支付宝账号']], + ['remark', 'string', ['limit' => 200, 'default' => '', 'null' => true, 'comment' => '提现描述']], + ['trade_no', 'string', ['limit' => 100, 'default' => '', 'null' => true, 'comment' => '交易单号']], + ['trade_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '打款时间']], + ['change_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '处理时间']], + ['change_desc', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '处理描述']], + ['audit_time', 'string', ['limit' => 20, 'default' => '', 'null' => true, 'comment' => '审核时间']], + ['audit_status', 'integer', ['limit' => 1, 'default' => 0, 'null' => true, 'comment' => '审核状态']], + ['audit_remark', 'string', ['limit' => 500, 'default' => '', 'null' => true, 'comment' => '审核描述']], + ['status', 'integer', ['limit' => 1, 'default' => 1, 'null' => true, 'comment' => '提现状态(0失败,1待审核,2已审核,3打款中,4已打款,5已收款)']], + ['create_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '创建时间']], + ['update_time', 'datetime', ['default' => NULL, 'null' => true, 'comment' => '更新时间']], + ], [ + 'code', 'unid', 'date', 'type', 'appid', 'openid', 'status', 'create_time', 'audit_status', + ], true); + } +}