M240222084407QimallAddonsAgentSupplierOrder.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace addons\Agent\console\migrations;
  3. use common\models\common\Addons;
  4. use yii\db\Migration;
  5. /**
  6. * Class M240222084407QimallAddonsAgentSupplierOrder
  7. */
  8. class M240222084407QimallAddonsAgentSupplierOrder extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $table = 'qimall_addons_agent_supplier_order';
  16. $sql="select * from information_schema.TABLES where TABLE_NAME = '{$table}';";
  17. $res = $this->db->createCommand($sql)->execute();
  18. if(!empty($res)) return '';
  19. $sql = "CREATE TABLE `qimall_addons_agent_supplier_order` (
  20. `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  21. `mall_id` int(11) unsigned NOT NULL DEFAULT '0',
  22. `buy_user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '买家id',
  23. `buy_level` int(11) NOT NULL DEFAULT '0' COMMENT '买家身份',
  24. `seller_user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '卖家id',
  25. `seller_level` int(11) NOT NULL DEFAULT '0' COMMENT '卖家身份',
  26. `order_no` varchar(100) NOT NULL DEFAULT '' COMMENT '会员订单号',
  27. `supplier_order_no` varchar(100) NOT NULL DEFAULT '' COMMENT '供应商订单号',
  28. `goods_nums` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '商品数量',
  29. `stock_nums` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '库存加减',
  30. `payment_amount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '货款金额',
  31. `profit` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '利润',
  32. `pay_time` int(11) NOT NULL DEFAULT '0' COMMENT '订单支付时间',
  33. `created_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间戳',
  34. `updated_at` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间戳',
  35. PRIMARY KEY (`id`) USING BTREE,
  36. KEY `idx_order_no` (`order_no`),
  37. KEY `idx_buy_user_id` (`buy_user_id`),
  38. KEY `idx_seller_user_id` (`seller_user_id`)
  39. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='供应商订单';";
  40. $this->execute($sql);
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function safeDown()
  46. {
  47. echo "M240222084407QimallAddonsAgentSupplierOrder cannot be reverted.\n";
  48. return false;
  49. }
  50. /*
  51. // Use up()/down() to run migration code without a transaction.
  52. public function up()
  53. {
  54. }
  55. public function down()
  56. {
  57. echo "M240222084407QimallAddonsAgentSupplierOrder cannot be reverted.\n";
  58. return false;
  59. }
  60. */
  61. }