123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- use think\migration\Migrator;
- use think\migration\db\Column;
- class CreateOrderTjTable extends Migrator
- {
- /**
- * Change Method.
- *
- * Write your reversible migrations using this method.
- *
- * More information on writing migrations is available here:
- * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
- *
- * The following commands can be used in this method and Phinx will
- * automatically reverse them when rolling back:
- *
- * createTable
- * renameTable
- * addColumn
- * renameColumn
- * addIndex
- * addForeignKey
- *
- * Remember to call "create()" or "update()" and NOT "save()" when working
- * with the Table class.
- */
- /*
- SELECT sum(total_price+express_price) as t1,
- sum(total_price) as t2,sum(pay_price+rice_card_money+rice_card_express_money) as t3,sum(express_price) as t4,
- sum(coupon_money) as t5,count(distinct(user_id)) as t6,count(*) as t7
- $t1 = $result[0]['t1'];//应付总金额(含运费)
- $t2 = $result[0]['t2'];//应付商品总金额
- $t3 = $result[0]['t3'];//实付金额(含运费)
- $t4 = $result[0]['t4'];//运费
- $t5 = $result[0]['t5'];//平台优惠券抵扣
- $t6 = $result[0]['t6'];//成交用户数
- $t7 = $result[0]['t7'];//订单数
- $t8 = $t3/$t6; //客单价
- */
- public function change()
- {
- $table = $this->table('order_tj',array('id' => true,'primary_key' => ['id'],'engine'=>'InnoDB','comment'=>'订单统计记录'));
- $table->addColumn('create_time', 'integer', array('limit' => 10,'signed' => false, 'default' => 0, 'comment' => '创建时间'))
- ->addColumn('remark', 'string',array('limit' => 255,'default'=>'','comment'=>'备注'))
- ->addColumn('ftype', 'integer',array('limit' => 10,'default'=>0,'comment'=>'1:日,2:周,3:月'))
- ->addColumn('total_price', 'decimal',array('limit' => 11,'precision'=>10,'scale'=>2,'signed'=>false,'default'=>0,'comment'=>'应付总金额(含运费)'))
- ->addColumn('total_goods_price', 'decimal',array('limit' => 11,'precision'=>10,'scale'=>2,'signed'=>false,'default'=>0,'comment'=>'应付商品总金额'))
- ->addColumn('total_pay_price', 'decimal',array('limit' => 11,'precision'=>10,'scale'=>2,'signed'=>false,'default'=>0,'comment'=>'实付金额(含运费)'))
- ->addColumn('total_express_price', 'decimal',array('limit' =>11,'precision'=>10,'scale'=>2,'signed'=>false,'default'=>0,'comment'=>'运费)'))
- ->addColumn('total_coupon_price', 'decimal',array('limit' => 11,'precision'=>10,'scale'=>2,'signed'=>false,'default'=>0,'comment'=>'平台优惠券抵扣)'))
- ->addColumn('total_users', 'integer',array('limit' => 11,'signed'=>false,'default'=>0,'comment'=>'成交用户数)'))
- ->addColumn('total_orders', 'integer',array('limit' => 11,'signed'=>false,'default'=>0,'comment'=>'成交订单数)'))
- ->addColumn('pcts', 'decimal',array('limit' => 11,'precision'=>10,'scale'=>2,'signed'=>false,'default'=>0,'comment'=>'客单价'))
- ->addColumn('tj_time', 'datetime', array('comment' => '统计时间'))
- ->create();
- }
- }
|