4 changed files with 11 additions and 253 deletions
-
80app/Console/Commands/MigrateOrderGoods.php
-
96app/Console/Commands/MigrateOrderMain.php
-
22app/Console/Commands/MigrateStoreWithdrawal.php
-
66app/Console/Commands/OnlineOrderStatis.php
@ -1,80 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Console\Commands; |
|
||||
|
|
||||
use Illuminate\Console\Command; |
|
||||
use Illuminate\Support\Facades\DB; |
|
||||
|
|
||||
class MigrateOrderGoods extends Command |
|
||||
{ |
|
||||
/** |
|
||||
* The name and signature of the console command. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $signature = 'migrateData:orderGoods'; |
|
||||
|
|
||||
/** |
|
||||
* The console command description. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $description = 'migrate order goods data'; |
|
||||
|
|
||||
/** |
|
||||
* Create a new command instance. |
|
||||
* |
|
||||
* @return void |
|
||||
*/ |
|
||||
public function __construct() |
|
||||
{ |
|
||||
parent::__construct(); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Execute the console command. |
|
||||
* |
|
||||
* @return int |
|
||||
*/ |
|
||||
public function handle() |
|
||||
{ |
|
||||
|
|
||||
// get old data from old table
|
|
||||
$oldData = DB::table('ims_cjdc_order_goods')->get(); |
|
||||
|
|
||||
$bar = $this->output->createProgressBar(count($oldData)); |
|
||||
$bar->start(); |
|
||||
|
|
||||
$newData = []; |
|
||||
foreach ($oldData as $key => $value) { |
|
||||
|
|
||||
$goods =DB::table('ims_cjdc_goods')->find($value->good_id); |
|
||||
|
|
||||
$newData[] = [ |
|
||||
'order_id' => $value->order_id ?? 0, |
|
||||
'goods_id' => $value->good_id ?? 0, |
|
||||
'number' => $value->number ?? 0, |
|
||||
'status' => 1, |
|
||||
'price' => $value->money ?? 0, |
|
||||
'original_price' => $goods->money2 ?? 0, |
|
||||
'vip_price' => $goods->vip_money ?? 0, |
|
||||
'name' => $value->name ?? '', |
|
||||
'goods_unit' => $value->good_unit ?? '', |
|
||||
'cover_img' => $value->img ?? '', |
|
||||
'spec' => json_encode([]), |
|
||||
'refund_time' => 0, |
|
||||
'created_at' => time(), |
|
||||
'updated_at' => time(), |
|
||||
'refuse_refund_note' => '', |
|
||||
]; |
|
||||
|
|
||||
$bar->advance(); |
|
||||
} |
|
||||
|
|
||||
// insert new data to new table
|
|
||||
DB::table('lanzu_order_goods')->insert($newData); |
|
||||
|
|
||||
$bar->finish(); |
|
||||
return 0; |
|
||||
} |
|
||||
} |
|
||||
@ -1,96 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Console\Commands; |
|
||||
|
|
||||
use Illuminate\Console\Command; |
|
||||
use Illuminate\Support\Facades\DB; |
|
||||
|
|
||||
class MigrateOrderMain extends Command |
|
||||
{ |
|
||||
/** |
|
||||
* The name and signature of the console command. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $signature = 'migrateData:orderMain'; |
|
||||
|
|
||||
/** |
|
||||
* The console command description. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $description = 'migrate order main data'; |
|
||||
|
|
||||
/** |
|
||||
* Create a new command instance. |
|
||||
* |
|
||||
* @return void |
|
||||
*/ |
|
||||
public function __construct() |
|
||||
{ |
|
||||
parent::__construct(); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Execute the console command. |
|
||||
* |
|
||||
* @return int |
|
||||
*/ |
|
||||
public function handle() |
|
||||
{ |
|
||||
|
|
||||
// get old data from old table
|
|
||||
$oldData = DB::table('ims_cjdc_order_main')->get(); |
|
||||
|
|
||||
$bar = $this->output->createProgressBar(count($oldData)); |
|
||||
$bar->start(); |
|
||||
|
|
||||
$newData = []; |
|
||||
foreach ($oldData as $key => $value) { |
|
||||
|
|
||||
$newData[] = [ |
|
||||
'market_id' => $value->market_id ?? 0, |
|
||||
'order_num' => $value->order_num ?? '', |
|
||||
'global_order_id' => $value->global_order_id ?? 0, |
|
||||
'user_id' => $value->user_id ?? 0, |
|
||||
'pay_type' => $value->pay_type ?? 0, |
|
||||
'type' => $value->type ?? 0, |
|
||||
'order_type' => $value->order_type ?? 0, |
|
||||
'shipping_type' => $value->dada_status==0 ? 1 : 2, |
|
||||
'money' => $value->money ?? 0, |
|
||||
'total_money' => $value->total_money ?? 0, |
|
||||
'services_money' => 0, |
|
||||
'coupon_money' => $value->yhq_money2 ?? 0, |
|
||||
'delivery_money' => $value->dada_fee ?? 0, |
|
||||
'state' => $value->state ?? 0, |
|
||||
'pay_time' => $value->pay_time ? strtotime($value->pay_time) : 0, |
|
||||
'receive_time' => $value->jd_time ? strtotime($value->jd_time) : 0, |
|
||||
'delivery_time' => 0, |
|
||||
'complete_time' => $value->complete_time ? strtotime($value->complete_time) : 0, |
|
||||
'cancel_time' => $value->complete_time ? strtotime($value->complete_time) : 0, |
|
||||
'refund_time' => $value->refund_time ?? 0, |
|
||||
'tel' => $value->tel ?? '', |
|
||||
'address' => $value->address ?? '', |
|
||||
'lat' => $value->lat ?? '', |
|
||||
'lng' => $value->lng ?? '', |
|
||||
'name' => $value->name ?? '', |
|
||||
'print_num' => $value->print_num ?? 0, |
|
||||
'plat' => $value->plat ?? 0, |
|
||||
'refuse_refund_note' => $value->refuse_refund_note ?? '', |
|
||||
'delivery_time_note' => $value->delivery_time ?? '', |
|
||||
'total_refund_note' => $value->total_refund_note ?? '', |
|
||||
'note' => $value->note ?? '', |
|
||||
'created_at' => $value->time_add ?? 0, |
|
||||
'updated_at' => 0, |
|
||||
]; |
|
||||
|
|
||||
$bar->advance(); |
|
||||
} |
|
||||
|
|
||||
// insert new data to new table
|
|
||||
DB::table('lanzu_order_main')->insert($newData); |
|
||||
|
|
||||
$bar->finish(); |
|
||||
return 0; |
|
||||
} |
|
||||
} |
|
||||
@ -1,66 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Console\Commands; |
|
||||
|
|
||||
use Illuminate\Console\Command; |
|
||||
use DB; |
|
||||
|
|
||||
class OnlineOrderStatis extends Command |
|
||||
{ |
|
||||
/** |
|
||||
* The name and signature of the console command. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $signature = 'command:OnlineOrderStatis'; |
|
||||
|
|
||||
/** |
|
||||
* The console command description. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $description = 'Command 在线订单情况统计'; |
|
||||
|
|
||||
/** |
|
||||
* Create a new command instance. |
|
||||
* |
|
||||
* @return void |
|
||||
*/ |
|
||||
public function __construct() |
|
||||
{ |
|
||||
parent::__construct(); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* Execute the console command. |
|
||||
* |
|
||||
* @return int |
|
||||
*/ |
|
||||
public function handle() |
|
||||
{ |
|
||||
|
|
||||
$ret = DB::select("select main.id as '系统订单号',
|
|
||||
main.order_num '订单号', |
|
||||
main.global_order_id '全局订单ID', |
|
||||
main.money '实付金额', |
|
||||
main.total_money '订单原金额', |
|
||||
main.yhq_money2 '优惠金额', |
|
||||
market.name '市场名', |
|
||||
main.user_id '下单用户ID', |
|
||||
user.name '系统用户名', |
|
||||
main.name '下单用户名', |
|
||||
main.address '下单用户地址', |
|
||||
FROM_UNIXTIME(main.time_add,'%Y-%m-%d %H:%i:%s') '下单时间' |
|
||||
FROM ims_cjdc_order_main `main` |
|
||||
INNER JOIN ims_cjdc_user `user` ON user.id=main.user_id |
|
||||
INNER JOIN `ims_cjdc_market` `market` ON main.`market_id`=market.id |
|
||||
where `time_add` >= 1599148800 and `time_add` <=1599235199 and `type` = 1 and state IN (4,5,10)");
|
|
||||
|
|
||||
$totalCount = count($ret); |
|
||||
foreach ($ret as $key => $item) { |
|
||||
|
|
||||
} |
|
||||
|
|
||||
return 0; |
|
||||
} |
|
||||
} |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue