1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- use app\api\model\shop\Shops;
- use app\api\model\Order;
- use app\common\model\ShopsDailySalesSt;
- use think\migration\Seeder;
- use think\facade\Db;
- class GenHistoryShopDailySalesSeeder extends Seeder
- {
- /**
- * Run Method.
- *
- * Write your database seeder using this method.
- *
- * More information on writing seeders is available here:
- * http://docs.phinx.org/en/latest/seeding.html
- */
- public function run()
- {
- $shops = Shops::where('is_delete',0)->field('shop_id,province_id,city_id,region_id')->select();
- Db::execute("truncate table yoshop_shop_daily_sales_st");
- $m = new ShopsDailySalesSt();
- $orderM = new Order();
- $datas = [];
- $baseTo = strtotime(date("Y-m-d"),time());
- $now = time();
- for ($i=1;$i<72;$i++){
- foreach ($shops as $shop) {
- $from = $baseTo - 86400*$i;
- $dayMid = $from + 43200;
- $to = $from + 86399;
- $temp = [];
- $tj = $orderM->dailySalesTj($shop['shop_id'],$from,$to);
- $temp['total_price'] = $tj['total_price'];
- $temp['total_goods_price'] = $tj['total_goods_price'];
- $temp['total_pay_price'] = $tj['total_pay_price'];
- $temp['coupon_money'] = $tj['coupon_money'];
- $temp['order_count'] = $tj['order_count'];
- $temp['express_price'] = $tj['express_price'];
- $temp['boss_comm_money'] = $tj['boss_comm_money'];
- $temp['mg_comm_money'] = $tj['mg_comm_money'];
- $temp['seller_comm_money'] = $tj['seller_comm_money'];
- $temp['shop_id'] = $shop['shop_id'];
- $temp['st_time'] = $dayMid;
- $temp['create_time'] = $now;
- $temp['update_time'] = $now;
- $datas[] = $temp;
- }
- }
- $m->insertAll($datas);
- }
- }
|