| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
- namespace addons\CloudStock\console\migrations;
- use addons\CloudStock\common\services\AgentService;
- use addons\CloudStock\common\services\CloudStockStatisticService;
- use addons\CloudStock\common\services\EqualAwardService;
- use common\models\mall\Mall;
- use yii\db\Migration;
- /**
- * Class M241203101341Huolihuoban2
- */
- class M241203101341Huolihuoban2 extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- $sql = "CREATE TABLE `qimall_addons_cloud_stock_price_difference_profit` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `mall_id` int(11) NOT NULL COMMENT '商城id',
- `user_id` int(11) NOT NULL COMMENT '代理商用户id',
- `order_no` varchar(255) NOT NULL COMMENT '订单编号',
- `type` tinyint(1) NOT NULL default 0 COMMENT '业务类型:1:上级配货,2:下级补货;3:会员买货',
- `child_id` int(11) NOT NULL COMMENT '下级代理商用户id',
- `num` int(11) NOT NULL default 0 COMMENT '商品件数',
- `money` decimal(12,2) NOT NULL default 0 COMMENT '价差利润',
- `goods_id` int(11) NOT NULL default 0 COMMENT '商品id',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` int(11) NOT NULL DEFAULT '0',
- `updated_at` int(11) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`) USING BTREE,
- KEY (`user_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='差价利润表';
- CREATE TABLE `qimall_addons_cloud_stock_loss_amount` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `mall_id` int(11) NOT NULL COMMENT '商城id',
- `user_id` int(11) NOT NULL COMMENT '代理商用户id',
- `order_no` varchar(255) NOT NULL COMMENT '订单编号',
- `type` tinyint(1) NOT NULL default 0 COMMENT '业务类型:1:上级配货,2:下级补货;3:会员买货',
- `child_id` int(11) NOT NULL COMMENT '下级代理商用户id',
- `num` int(11) NOT NULL default 0 COMMENT '商品件数',
- `money` decimal(12,2) NOT NULL default 0 COMMENT '流失金额',
- `goods_id` int(11) NOT NULL default 0 COMMENT '商品id',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` int(11) NOT NULL DEFAULT '0',
- `updated_at` int(11) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`) USING BTREE,
- KEY (`user_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='流失金额表';
- CREATE TABLE `qimall_addons_cloud_stock_early_warning_log` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
- `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城ID',
- `user_id` int(11) NOT NULL DEFAULT '0' COMMENT '会员id',
- `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '导入的商品的id',
- `status` tinyint(1) NOT NULL DEFAULT 1,
- `updated_at` int(11) NOT NULL DEFAULT '0',
- `created_at` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
- PRIMARY KEY (`id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='库存预警通知发送日志';
- CREATE TABLE `qimall_addons_cloud_stock_statistic` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `mall_id` int(11) NOT NULL DEFAULT '0' COMMENT '商城id',
- `capital_type` varchar(255) NOT NULL DEFAULT '0' COMMENT '奖励类型',
- `settlement_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:待结算;1:已结算',
- `money` decimal(12,2) NOT NULL DEFAULT '0' COMMENT '数量',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` int(11) NOT NULL DEFAULT '0',
- `updated_at` int(11) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `mall_id` (`mall_id`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='云库存奖励统计';
- CREATE TABLE `qimall_addons_cloud_stock_dispense_order` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `mall_id` int(11) NOT NULL COMMENT '商城id',
- `type` tinyint(3) NOT NULL DEFAULT '0' COMMENT '1上级配货;2:平台充值',
- `user_id` int(11) NOT NULL COMMENT '代理商用户id',
- `agent_price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '代理拿货价',
- `child_id` int(11) NOT NULL COMMENT '配货下级用户id',
- `child_price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '配货下级的拿货价',
- `money` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '配货金额',
- `order_no` varchar(255) NOT NULL COMMENT '补货订单编号',
- `goods_id` int(11) NOT NULL COMMENT '商品id',
- `num` int(11) NOT NULL DEFAULT '0' COMMENT '补货商品数量',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]',
- `created_at` int(11) NOT NULL DEFAULT '0',
- `updated_at` int(11) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`) USING BTREE,
- KEY `user_id` (`user_id`) USING BTREE,
- KEY `order_no` (`order_no`) USING BTREE
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='配货订单表';
- ALTER table qimall_addons_cloud_stock_agent add `equal_award_frozen_price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '待结算平级奖';
- ALTER table qimall_addons_cloud_stock_agent add `equal_award_price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '已结算平级奖';
- ALTER table qimall_addons_cloud_stock_agent add `loss_amount` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '流失金额';
- ALTER table qimall_addons_cloud_stock_agent add `difference_profit` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '价差利润';
- ALTER TABLE qimall_addons_cloud_stock_agent add `is_equal_award_restriction` tinyint(1) not null DEFAULT 0 COMMENT '是否开启平级奖限制:1是;0:否';
- ALTER table qimall_addons_cloud_stock_goods add `warning_quantity` varchar(5) NOT NULL DEFAULT '' COMMENT '预警数量';
- ";
- $this->execute($sql);
- $this->execute("INSERT INTO `qimall_crontab_task` ( `name`, `command`, `type`, `rule`, `is_warning`, `status`, `created_at`, `updated_at`) VALUES ('云库存-平级奖结算', 'cloud-stock/index/settlement-equal-reward', 2, '0 0 1 * * *', 0, 1, 1735121957, 1735121957)");
- $mall_list = Mall::getEnableMallList(true);
- foreach ($mall_list as $mall) {
- (new EqualAwardService(['mall_id' => $mall['id']]))->fixOrderNo('commission');
- (new EqualAwardService(['mall_id' => $mall['id']]))->fixOrderNo('commission_frozen');
- (new CloudStockStatisticService(['mall_id' => $mall['id']]))->fix('commission');
- (new CloudStockStatisticService(['mall_id' => $mall['id']]))->fix('commission_frozen');
- (new AgentService(['mall_id' => $mall['id']]))->fix('commission');
- (new AgentService(['mall_id' => $mall['id']]))->fix('commission_frozen');
- }
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M241203101341Huolihuoban2 cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M241203101341Huolihuoban2 cannot be reverted.\n";
- return false;
- }
- */
- }
|