<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        DB::statement("CREATE TABLE `ufutx_s2_shop_order` (
  `id` bigint(20) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
  `trade_no` varchar(256) NOT NULL COMMENT '订单号',
  `user_id` bigint(20) UNSIGNED NOT NULL COMMENT '用户id',
  `spu_id` bigint(20) UNSIGNED NOT NULL COMMENT '商品id',
  `sku_id` bigint(20) UNSIGNED NOT NULL COMMENT '原始skuid',
  `snapshot_id` bigint(20) UNSIGNED NOT NULL COMMENT '快照id',
  `num` int(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '购买数量',
  `num_stock_total` int(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '实际单品sku的购买总数',
  `nums_lock` varchar(256) NOT NULL COMMENT '各sku的锁定数量',
  `nums_reject` varchar(256) NOT NULL COMMENT '各sku的已退款数量',
  `nums_send` varchar(256) NOT NULL COMMENT '各sku的已发货数量',
  `nums_signed` varchar(256) NOT NULL COMMENT '各sku的已签收数量',
  `price_origin` bigint(20) NOT NULL COMMENT '原始价格,单价*数量,单位:分',
  `price_final` bigint(20) NOT NULL COMMENT '最终支付价格,单位:分',
  `freight` bigint(20) NOT NULL COMMENT '总运费,单位:分',
  `remark` text NOT NULL COMMENT '备注',
  `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1=未支付,2=已支付,3=退款中,4=已退款,5=退款被拒绝',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单表';");
        DB::statement("CREATE TABLE `ufutx_s2_shop_snapshot` (
  `id` bigint(20) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
  `payment_id` tinyint(3) UNSIGNED NOT NULL COMMENT '支付子商户id',
  `spu_id` bigint(20) UNSIGNED NOT NULL COMMENT '原始商品id',
  `sku_id` bigint(20) UNSIGNED NOT NULL COMMENT '原始skuid',
  `sku_title` varchar(256) NOT NULL COMMENT 'sku名称',
  `icon` varchar(256) DEFAULT NULL COMMENT '图标',
  `tpl_price` text COMMENT '价格模板',
  `tpl_freight` text COMMENT '运费模板',
  `type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1=单品,2=sku组合',
  `group_ids` varchar(256) NOT NULL COMMENT 'sku快照id组合,逗号分割',
  `group_num` varchar(256) NOT NULL COMMENT 'sku组合数量限制,总量|sku1最大,sku2最大...',
  `ship` tinyint(3) UNSIGNED NOT NULL DEFAULT '3' COMMENT '1=仅自提,2=仅邮寄,3=皆可',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品sku快照表';");
        DB::statement("CREATE TABLE `ufutx_s2_shop_express` (
  `id` bigint(20) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
  `order_id` bigint(20) UNSIGNED NOT NULL COMMENT '订单id',
  `trade_no` varchar(256) NOT NULL COMMENT '订单号',
  `express` varchar(256) DEFAULT NULL COMMENT '快递公司',
  `express_no` varchar(256) DEFAULT NULL COMMENT '快递单号',
  `sku_ids` varchar(256) NOT NULL COMMENT 'skuid,逗号分隔',
  `send_nums` varchar(256) NOT NULL COMMENT '发货数量,逗号分隔',
  `send_num_total` int(10) UNSIGNED NOT NULL DEFAULT '1' COMMENT '总发货数量',
  `name` varchar(256) NOT NULL COMMENT '收货人',
  `mobile` varchar(256) NOT NULL COMMENT '电话',
  `address` varchar(512) NOT NULL COMMENT '收货地址',
  `ship` tinyint(3) UNSIGNED NOT NULL DEFAULT '1' COMMENT '1-自提,2=邮寄',
  `remark` text NOT NULL COMMENT '备注',
  `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1=待审核,2=审核不通过,3=待发货,4=已发货,5=已签收',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='快递信息';");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('s2_shop_order');
        Schema::dropIfExists('s2_shop_snapshot');
        Schema::dropIfExists('s2_shop_express');
    }
};
