From e2973cbffb34d011ef966c4edd06261e84b8cb81 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Wed, 16 Sep 2020 18:53:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=97=E9=93=BA=5Fnew=E6=8D=A2=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/v3/GoodsNewController.php | 2 +- app/Console/Commands/MigrateGoods.php | 160 ------------------ .../Commands/MigrateOrderStatistics.php | 2 +- app/Console/Commands/MigrateStore.php | 4 +- app/Models/v3/Store.php | 2 +- 5 files changed, 5 insertions(+), 165 deletions(-) delete mode 100644 app/Console/Commands/MigrateGoods.php diff --git a/app/Admin/Controllers/v3/GoodsNewController.php b/app/Admin/Controllers/v3/GoodsNewController.php index ce6f1ea..3317b5d 100644 --- a/app/Admin/Controllers/v3/GoodsNewController.php +++ b/app/Admin/Controllers/v3/GoodsNewController.php @@ -89,7 +89,7 @@ class GoodsNewController extends AdminController $filter->equal('goods_unit'); }); - $grid->model()->orderBy('category_id', 'asc'); + $grid->model()->orderBy('goods_category_id', 'asc'); // 每页10条 $grid->paginate(10); }); diff --git a/app/Console/Commands/MigrateGoods.php b/app/Console/Commands/MigrateGoods.php deleted file mode 100644 index 1f125c7..0000000 --- a/app/Console/Commands/MigrateGoods.php +++ /dev/null @@ -1,160 +0,0 @@ -orderBy('id','asc')->get(); - $oldStoreData = DB::table($oldStoreTableName)->pluck('market_id','id'); - $bar = $this->output->createProgressBar(count($oldData)); - $bar->start(); - $startTime = time(); - $total = 0; - $error = []; - foreach ($oldData as $value){ - $goodsId = $value->id; - // 判断店铺是否存在,如果商品的店铺不在,则不存这个商品 - $storeExist = DB::table($oldStoreTableName)->where('id',$value->store_id)->exists(); - if(!$storeExist){ - continue; - } - $goodsData =[ - // 'id'=>$value->id, - 'market_id' => $oldStoreData[$value->store_id], - 'store_id'=>$value->store_id, - 'on_sale'=> $value->is_show == 1 ? 1 : 0, - 'sort'=>$value->num, - 'price'=>$value->money, - 'original_price'=> ($value->money2 < $value->money)?$value->money:$value->money2, - 'vip_price'=>$value->vip_money, - 'sales'=>$value->sales, - 'start_num'=>$value->start_num, - 'restrict_num'=>$value->restrict_num, - 'is_infinite'=> $value->is_max == 1 ? 1 :0, - 'inventory'=>$value->inventory, - 'name'=>$value->name, - 'cover_img'=>$value->logo, - 'goods_unit'=>$value->good_unit, - - 'content'=> strip_tags($value->content), - 'details'=> strip_tags($value->details), - - 'created_at' => time(), - 'updated_at' => time(), - ]; - $specs = DB::table($oldSpecTableName)->where('good_id',$goodsId)->get(); - if(count($specs) > 0){ - foreach($specs as $vs){ - $spec = ['spec_key'=>'净含量','spec_value'=>$vs->combination]; - if(strstr($vs->combination,'辣')){ - $spec['spec_key'] = '口味'; - }else if(strstr($vs->combination,'馅')){ - $spec['spec_key'] = '馅料'; - }else if(strstr($vs->combination,'mm')){ - $spec['spec_key'] = '尺寸'; - } - - $goodsData['spec'] = json_encode([$spec]); - - $newData = $goodsData; - $newBanner = [ - 'type' =>1, - 'path' =>$value->logo, - 'created_at' =>time(), - 'updated_at' =>time(), - ]; - $id = DB::table($newTableName)->insertGetId($newData); - - if(!$id){ - $error[] = ['id'=>$goodsId]; - break; - } - $newBanner['goods_id'] = $id; - DB::table($newBannerTableName)->insertGetId($newBanner); - $total++; - } - }else{ - $newData = $goodsData; - $res= $id = DB::table($newTableName)->insertGetId($newData); - if(!$res){ - $error[] = ['id'=>$goodsId]; - break; - } - $newBanner['goods_id'] = $id; - DB::table($newBannerTableName)->insertGetId($newBanner); - $total++; - } - $bar->advance(); - } - - $bar->finish(); - var_dump([time()-$startTime]); - var_dump($total); - var_dump($error); - return 0; - } -} diff --git a/app/Console/Commands/MigrateOrderStatistics.php b/app/Console/Commands/MigrateOrderStatistics.php index c2bab97..88c735b 100644 --- a/app/Console/Commands/MigrateOrderStatistics.php +++ b/app/Console/Commands/MigrateOrderStatistics.php @@ -40,7 +40,7 @@ class MigrateOrderStatistics extends Command public function handle() { $oldTableName = 'ims_cjdc_order_sales_statistics'; - $newTableName = 'lanzu_order_sales_statistics_copy'; + $newTableName = 'lanzu_order_sales_statistics'; // 判断表是否存在 if(!Schema::hasTable($oldTableName)){ var_dump('旧表不存在'); diff --git a/app/Console/Commands/MigrateStore.php b/app/Console/Commands/MigrateStore.php index 6d4d42f..235e28e 100644 --- a/app/Console/Commands/MigrateStore.php +++ b/app/Console/Commands/MigrateStore.php @@ -39,8 +39,8 @@ class MigrateStore extends Command */ public function handle() { - $oldTableName = 'ims_cjdc_store_new'; - $newTableName = 'lanzu_store_new'; + $oldTableName = 'ims_cjdc_store'; + $newTableName = 'lanzu_store'; // $storeImgPath = 'QR_code/code_store_img/wx_store_';/* 商户小程序码 */ // $storePayPath = 'QR_code/code_pay_img/wx_pay_';/* 收银二维码 */ // 判断表是否存在 diff --git a/app/Models/v3/Store.php b/app/Models/v3/Store.php index 2988381..7d9f95b 100644 --- a/app/Models/v3/Store.php +++ b/app/Models/v3/Store.php @@ -11,7 +11,7 @@ class Store extends Model use HasDateTimeFormatter; use SoftDeletes; - protected $table = 'lanzu_store_new'; + protected $table = 'lanzu_store'; protected $dateFormat = 'U'; /* 查询记录数 limit */