30 changed files with 826 additions and 143 deletions
-
36app/Admin/Actions/Grid/v3/StoreSetTime.php
-
2app/Admin/Controllers/v3/BannersController.php
-
52app/Admin/Controllers/v3/GoodsActivityController.php
-
47app/Admin/Controllers/v3/GoodsController.php
-
30app/Admin/Controllers/v3/GoodsNewController.php
-
86app/Admin/Controllers/v3/ServicePersonnelController.php
-
2app/Admin/Controllers/v3/StoreController.php
-
3app/Admin/Forms/GoodsCopyForm.php
-
3app/Admin/Forms/GoodsNewCopyForm.php
-
3app/Admin/Forms/GoodsNewImageForm.php
-
65app/Admin/Forms/v3/StoreSetTimeForm.php
-
16app/Admin/Repositories/v3/ServicePersonnel.php
-
3app/Admin/routes.php
-
139app/Console/Commands/MigrateCoupon.php
-
89app/Console/Commands/MigrateCouponReceive.php
-
84app/Console/Commands/MigrateCouponUse.php
-
16app/Console/Commands/MigrateFePrint.php
-
4app/Console/Commands/MigrateMarketData.php
-
14app/Console/Commands/MigrateOrder.php
-
79app/Console/Commands/MigrateOrderStatistics.php
-
21app/Console/Commands/MigrateStoreBalance.php
-
4app/Console/Commands/MigrateStoreFinancial.php
-
79app/Console/Commands/MigrateStoreImg.php
-
2app/Console/Commands/MigrateUserAddr.php
-
3app/Models/v3/GoodsActivity.php
-
16app/Models/v3/ServicePersonnel.php
-
40database/migrations/2020_09_14_120733_create_lanzu_service_personnel_table.php
-
4dcat_admin_ide_helper.php
-
3resources/lang/zh-CN/goods-activity.php
-
22resources/lang/zh-CN/service-personnel.php
@ -0,0 +1,36 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Actions\Grid\v3; |
||||
|
|
||||
|
use Dcat\Admin\Grid\RowAction; |
||||
|
use Dcat\Admin\Widgets\Modal; |
||||
|
use App\Admin\Forms\v3\StoreSetTimeForm; |
||||
|
|
||||
|
class StoreSetTime extends RowAction |
||||
|
{ |
||||
|
/** |
||||
|
* @return string |
||||
|
*/ |
||||
|
protected $title = '营业时间'; |
||||
|
|
||||
|
public function render() |
||||
|
{ |
||||
|
$id = $this->getKey(); |
||||
|
|
||||
|
$modal = Modal::make() |
||||
|
->xl() |
||||
|
->title($this->title) |
||||
|
->body(StoreSetTimeForm::make()->setKey($id)) |
||||
|
->button($this->title); |
||||
|
|
||||
|
return $modal; |
||||
|
} |
||||
|
|
||||
|
public function parameters() |
||||
|
{ |
||||
|
|
||||
|
return [ |
||||
|
|
||||
|
]; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,86 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Controllers\v3; |
||||
|
|
||||
|
use App\Admin\Repositories\v3\ServicePersonnel; |
||||
|
use Dcat\Admin\Form; |
||||
|
use Dcat\Admin\Grid; |
||||
|
use Dcat\Admin\Show; |
||||
|
use Dcat\Admin\Controllers\AdminController; |
||||
|
|
||||
|
class ServicePersonnelController extends AdminController |
||||
|
{ |
||||
|
/** |
||||
|
* Make a grid builder. |
||||
|
* |
||||
|
* @return Grid |
||||
|
*/ |
||||
|
protected function grid() |
||||
|
{ |
||||
|
return Grid::make(new ServicePersonnel(), function (Grid $grid) { |
||||
|
$grid->column('id')->sortable(); |
||||
|
$grid->column('user_id'); |
||||
|
$grid->column('name'); |
||||
|
$grid->column('tel'); |
||||
|
$grid->column('market_id'); |
||||
|
$grid->column('type'); |
||||
|
$grid->column('status'); |
||||
|
$grid->column('qr_url'); |
||||
|
$grid->column('head_url'); |
||||
|
$grid->column('created_at'); |
||||
|
$grid->column('updated_at')->sortable(); |
||||
|
|
||||
|
$grid->filter(function (Grid\Filter $filter) { |
||||
|
$filter->equal('id'); |
||||
|
|
||||
|
}); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Make a show builder. |
||||
|
* |
||||
|
* @param mixed $id |
||||
|
* |
||||
|
* @return Show |
||||
|
*/ |
||||
|
protected function detail($id) |
||||
|
{ |
||||
|
return Show::make($id, new ServicePersonnel(), function (Show $show) { |
||||
|
$show->field('id'); |
||||
|
$show->field('user_id'); |
||||
|
$show->field('name'); |
||||
|
$show->field('tel'); |
||||
|
$show->field('market_id'); |
||||
|
$show->field('type'); |
||||
|
$show->field('status'); |
||||
|
$show->field('qr_url'); |
||||
|
$show->field('head_url'); |
||||
|
$show->field('created_at'); |
||||
|
$show->field('updated_at'); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Make a form builder. |
||||
|
* |
||||
|
* @return Form |
||||
|
*/ |
||||
|
protected function form() |
||||
|
{ |
||||
|
return Form::make(new ServicePersonnel(), function (Form $form) { |
||||
|
$form->display('id'); |
||||
|
$form->text('user_id'); |
||||
|
$form->text('name'); |
||||
|
$form->text('tel'); |
||||
|
$form->text('market_id'); |
||||
|
$form->text('type'); |
||||
|
$form->text('status'); |
||||
|
$form->text('qr_url'); |
||||
|
$form->text('head_url'); |
||||
|
|
||||
|
$form->display('created_at'); |
||||
|
$form->display('updated_at'); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Forms\v3; |
||||
|
|
||||
|
use Dcat\Admin\Widgets\Form; |
||||
|
use Symfony\Component\HttpFoundation\Response; |
||||
|
use App\Models\v3\Store as StoreModel; |
||||
|
|
||||
|
class StoreSetTimeForm extends Form |
||||
|
{ |
||||
|
|
||||
|
/** |
||||
|
* Handle the form request. |
||||
|
* |
||||
|
* @param array $input |
||||
|
* |
||||
|
* @return Response |
||||
|
*/ |
||||
|
public function handle(array $input) |
||||
|
{ |
||||
|
// 获取外部传递参数
|
||||
|
$storeId = $input['store_id']; |
||||
|
|
||||
|
$store = StoreModel::find($storeId); |
||||
|
$store->time1 = $input['time1']; |
||||
|
$store->time2 = $input['time2']; |
||||
|
$store->time3 = $input['time3']; |
||||
|
$store->time4 = $input['time4']; |
||||
|
if($store->save()){ |
||||
|
return $this->success('修改成功', '/store'); |
||||
|
} |
||||
|
return $this->error('修改失败'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Build a form here. |
||||
|
*/ |
||||
|
public function form() |
||||
|
{ |
||||
|
$id = $this->getKey(); |
||||
|
$store = StoreModel::select('name','time1','time2','time3','time4')->find($id); |
||||
|
$this->hidden('store_id')->value($id); |
||||
|
$name = empty($store->name)?'':$store->name; |
||||
|
$time1 = empty($store->time1)?'':$store->time1; |
||||
|
$time2 = empty($store->time2)?'':$store->time2; |
||||
|
$time3 = empty($store->time3)?'':$store->time3; |
||||
|
$time4 = empty($store->time4)?'':$store->time4; |
||||
|
$this->display('name','店铺名称')->value($name); |
||||
|
$this->time('time1','时间段一开始')->format('HH:mm')->value($time1); |
||||
|
$this->time('time2','时间段一结束')->format('HH:mm')->rules('after:time1',['after'=>'选择的时间必须比时间段一开始时间晚'])->value($time2); |
||||
|
$this->time('time3','时间段二开始')->format('HH:mm')->rules('after:time2',['after'=>'选择的时间必须比时间段一结束时间晚'])->value($time3); |
||||
|
$this->time('time4','时间段二结束')->format('HH:mm')->rules('after:time3',['after'=>'选择的时间必须比时间段二开始时间晚'])->value($time4); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* The data of the form. |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function default() |
||||
|
{ |
||||
|
return []; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Repositories\v3; |
||||
|
|
||||
|
use App\Models\v3\ServicePersonnel as Model; |
||||
|
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
|
||||
|
class ServicePersonnel extends EloquentRepository |
||||
|
{ |
||||
|
/** |
||||
|
* Model. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $eloquentClass = Model::class; |
||||
|
} |
||||
@ -0,0 +1,139 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Console\Commands; |
||||
|
|
||||
|
use Illuminate\Console\Command; |
||||
|
use Illuminate\Support\Facades\DB; |
||||
|
use Illuminate\Support\Facades\Schema; |
||||
|
|
||||
|
class MigrateCoupon extends Command |
||||
|
{ |
||||
|
/** |
||||
|
* The name and signature of the console command. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $signature = 'migrateData:coupon'; |
||||
|
|
||||
|
/** |
||||
|
* The console command description. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $description = 'migrate 迁移优惠券数据'; |
||||
|
|
||||
|
/** |
||||
|
* Create a new command instance. |
||||
|
* |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Execute the console command. |
||||
|
* |
||||
|
* @return int |
||||
|
*/ |
||||
|
public function handle() |
||||
|
{ |
||||
|
$oldSetTableName = 'ims_system_coupon_setting'; |
||||
|
$oldTableName = 'ims_system_coupon_user'; |
||||
|
$oldTypeTableName = 'ims_system_coupon_user_receivetype'; |
||||
|
$newSetTableName = 'lanzu_coupon_setting'; |
||||
|
$newTableName = 'lanzu_coupon'; |
||||
|
$newTypeTableName = 'lanzu_coupon_receive_type'; |
||||
|
|
||||
|
// 判断表是否存在
|
||||
|
if(!Schema::hasTable($oldTableName)){ |
||||
|
var_dump('旧表不存在'); |
||||
|
return 0; |
||||
|
} |
||||
|
if(!Schema::hasTable($newTableName)){ |
||||
|
var_dump('新表不存在'); |
||||
|
return 0; |
||||
|
} |
||||
|
$oldSetData = DB::table($oldSetTableName)->get(); |
||||
|
$oldData = DB::table($oldTableName)->get(); |
||||
|
$oldTypeData = DB::table($oldTypeTableName)->get(); |
||||
|
$bar = $this->output->createProgressBar(count($oldData)); |
||||
|
$bar->start(); |
||||
|
|
||||
|
$newSetData = []; |
||||
|
$newData = []; |
||||
|
$newTypeData = []; |
||||
|
foreach ($oldSetData as $key => $value) { |
||||
|
$newSetData[] = [ |
||||
|
'id' => $value->id, |
||||
|
'name' => $value->name ?? 0, |
||||
|
'category' => $value->category ?? 0, |
||||
|
'value' => $value->value ?? 0, |
||||
|
'desc' => $value->desc ?? '', |
||||
|
'sort' => $value->sort ?? 0, |
||||
|
'status' => $value->status ?? 0, |
||||
|
|
||||
|
'created_at' => time(), |
||||
|
'updated_at' => time(), |
||||
|
]; |
||||
|
} |
||||
|
foreach ($oldData as $key => $value) { |
||||
|
$newData[] = [ |
||||
|
'id' => $value->id, |
||||
|
'status' => $value->status ?? 0, |
||||
|
'active_type' => $value->active_type ?? 0, |
||||
|
'type' => $value->type ?? 0, |
||||
|
'title' => $value->title ?? '', |
||||
|
'introduce' => $value->introduce ?? '', |
||||
|
'start_time' => $value->start_time ?? 0, |
||||
|
'end_time' => $value->end_time, |
||||
|
'full_amount' => $value->full_amount, |
||||
|
'discounts' => $value->discounts ?? 0, |
||||
|
'is_new_user' => $value->is_new_user ?? 0, |
||||
|
|
||||
|
'inventory' => $value->inventory, |
||||
|
'inventory_use' => $value->inventory_use ?? 0, |
||||
|
'market_ids' => json_encode([]), |
||||
|
'category_ids' => json_encode([]), |
||||
|
'category' => $value->category ?? 0, |
||||
|
'discount_type' => $value->discount_type ?? 0, |
||||
|
'activity_available' => json_encode([]), |
||||
|
'weigh' => $value->weigh ?? 0, |
||||
|
'usable_number' => $value->usable_number ?? 0, |
||||
|
'usable_start_time' => $value->usable_start_time ?? 0, |
||||
|
'usable_end_time' => $value->usable_end_time ?? 0, |
||||
|
|
||||
|
'remark' => $value->remark ?? 0, |
||||
|
'add_user_id' => $value->add_user_id ?? 0, |
||||
|
'update_user_id' => $value->update_user_id ?? 0, |
||||
|
'tags' => json_encode([]), |
||||
|
|
||||
|
'created_at' => $value->addtime ?? 0, |
||||
|
'updated_at' => time(), |
||||
|
'deleted_at' => $value->status == -1 ? time() : $value->deleted_at ?? null, |
||||
|
]; |
||||
|
} |
||||
|
foreach ($oldTypeData as $key => $value) { |
||||
|
$newTypeData[] = [ |
||||
|
'id' => $value->id, |
||||
|
'coupon_id' => $value->system_coupon_user_id ?? 0, |
||||
|
|
||||
|
'receive_type' => $value->receive_type ?? 0, |
||||
|
'one_receive_number' => $value->one_receive_number ?? 0, |
||||
|
|
||||
|
'created_at' => $value->add_time ?? 0, |
||||
|
'updated_at' => time(), |
||||
|
]; |
||||
|
$bar->advance(); |
||||
|
} |
||||
|
|
||||
|
// insert new data to new table
|
||||
|
DB::table($newSetTableName)->insert($newSetData); |
||||
|
DB::table($newTableName)->insert($newData); |
||||
|
DB::table($newTypeTableName)->insert($newTypeData); |
||||
|
|
||||
|
$bar->finish(); |
||||
|
return 0; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,89 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Console\Commands; |
||||
|
|
||||
|
use Illuminate\Console\Command; |
||||
|
use Illuminate\Support\Facades\DB; |
||||
|
use Illuminate\Support\Facades\Schema; |
||||
|
|
||||
|
class MigrateCouponReceive extends Command |
||||
|
{ |
||||
|
/** |
||||
|
* The name and signature of the console command. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $signature = 'migrateData:couponReceive'; |
||||
|
|
||||
|
/** |
||||
|
* The console command description. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $description = 'migrate 迁移优惠券领取记录数据'; |
||||
|
|
||||
|
/** |
||||
|
* Create a new command instance. |
||||
|
* |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Execute the console command. |
||||
|
* |
||||
|
* @return int |
||||
|
*/ |
||||
|
public function handle() |
||||
|
{ |
||||
|
|
||||
|
$oldTableName = 'ims_system_coupon_user_receive'; |
||||
|
$newTableName = 'lanzu_coupon_receive_copy'; |
||||
|
// 判断表是否存在
|
||||
|
if(!Schema::hasTable($oldTableName)){ |
||||
|
var_dump('旧表不存在'); |
||||
|
return 0; |
||||
|
} |
||||
|
if(!Schema::hasTable($newTableName)){ |
||||
|
var_dump('新表不存在'); |
||||
|
return 0; |
||||
|
} |
||||
|
$oldData = DB::table($oldTableName)->get(); |
||||
|
|
||||
|
$bar = $this->output->createProgressBar(count($oldData)); |
||||
|
$bar->start(); |
||||
|
|
||||
|
$newData = []; |
||||
|
foreach ($oldData as $key => $value) { |
||||
|
$newData[] = [ |
||||
|
'id' => $value->id, |
||||
|
'coupon_id' => $value->system_coupon_user_id ?? 0, |
||||
|
|
||||
|
'user_id' => $value->user_id ?? 0, |
||||
|
'order_main_id' => $value->order_main_id ?? 0, |
||||
|
'receive_time' => $value->receive_time ?? 0, |
||||
|
'number' => $value->number ?? 0, |
||||
|
'number_remain' => $value->number_remain ?? 0, |
||||
|
'status' => $value->status ?? 0, |
||||
|
'update_time' => $value->update_time ?? 0, |
||||
|
'receive_type' => $value->receive_type ?? 0, |
||||
|
|
||||
|
'rebate_type' => $value->rebate_type ?? 0, |
||||
|
'send_user_id' => $value->send_user_id ?? 0, |
||||
|
'phone' => $value->phone ?? '', |
||||
|
|
||||
|
'created_at' => $value->created_at ?? 0, |
||||
|
'updated_at' => time(), |
||||
|
]; |
||||
|
$bar->advance(); |
||||
|
} |
||||
|
// insert new data to new table
|
||||
|
DB::table($newTableName)->insert($newData); |
||||
|
|
||||
|
$bar->finish(); |
||||
|
return 0; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,84 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Console\Commands; |
||||
|
|
||||
|
use Illuminate\Console\Command; |
||||
|
use Illuminate\Support\Facades\DB; |
||||
|
use Illuminate\Support\Facades\Schema; |
||||
|
|
||||
|
class MigrateCouponUse extends Command |
||||
|
{ |
||||
|
/** |
||||
|
* The name and signature of the console command. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $signature = 'migrateData:couponUse'; |
||||
|
|
||||
|
/** |
||||
|
* The console command description. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $description = 'migrate 迁移优惠券使用记录数据'; |
||||
|
|
||||
|
/** |
||||
|
* Create a new command instance. |
||||
|
* |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Execute the console command. |
||||
|
* |
||||
|
* @return int |
||||
|
*/ |
||||
|
public function handle() |
||||
|
{ |
||||
|
|
||||
|
$oldTableName = 'ims_system_coupon_user_use'; |
||||
|
$newTableName = 'lanzu_coupon_use_copy'; |
||||
|
// 判断表是否存在
|
||||
|
if(!Schema::hasTable($oldTableName)){ |
||||
|
var_dump('旧表不存在'); |
||||
|
return 0; |
||||
|
} |
||||
|
if(!Schema::hasTable($newTableName)){ |
||||
|
var_dump('新表不存在'); |
||||
|
return 0; |
||||
|
} |
||||
|
$oldData = DB::table($oldTableName)->get(); |
||||
|
|
||||
|
$bar = $this->output->createProgressBar(count($oldData)); |
||||
|
$bar->start(); |
||||
|
|
||||
|
$newData = []; |
||||
|
foreach ($oldData as $key => $value) { |
||||
|
$newData[] = [ |
||||
|
'id' => $value->id, |
||||
|
'coupon_id' => $value->system_coupon_user_id ?? 0, |
||||
|
'user_id' => $value->user_id ?? 0, |
||||
|
|
||||
|
'order_main_id' => $value->order_main_id ?? 0, |
||||
|
'user_receive_id' => $value->user_receive_id ?? 0, |
||||
|
'number' => $value->number ?? 0, |
||||
|
'use_time' => $value->use_time ?? 0, |
||||
|
'status' => $value->status ?? 0, |
||||
|
'return_time' => $value->return_time ?? 0, |
||||
|
|
||||
|
'created_at' => $value->created_at ?? 0, |
||||
|
'updated_at' => time(), |
||||
|
]; |
||||
|
$bar->advance(); |
||||
|
} |
||||
|
// insert new data to new table
|
||||
|
DB::table($newTableName)->insert($newData); |
||||
|
|
||||
|
$bar->finish(); |
||||
|
return 0; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,79 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Console\Commands; |
||||
|
|
||||
|
use Illuminate\Console\Command; |
||||
|
use Illuminate\Support\Facades\DB; |
||||
|
use Illuminate\Support\Facades\Schema; |
||||
|
|
||||
|
class MigrateOrderStatistics extends Command |
||||
|
{ |
||||
|
/** |
||||
|
* The name and signature of the console command. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $signature = 'migrateData:orderStatistics'; |
||||
|
|
||||
|
/** |
||||
|
* The console command description. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $description = 'migrate 迁移订单统计数据'; |
||||
|
|
||||
|
/** |
||||
|
* Create a new command instance. |
||||
|
* |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Execute the console command. |
||||
|
* |
||||
|
* @return int |
||||
|
*/ |
||||
|
public function handle() |
||||
|
{ |
||||
|
$oldTableName = 'ims_cjdc_order_sales_statistics'; |
||||
|
$newTableName = 'lanzu_order_sales_statistics_copy'; |
||||
|
// 判断表是否存在
|
||||
|
if(!Schema::hasTable($oldTableName)){ |
||||
|
var_dump('旧表不存在'); |
||||
|
return 0; |
||||
|
} |
||||
|
if(!Schema::hasTable($newTableName)){ |
||||
|
var_dump('新表不存在'); |
||||
|
return 0; |
||||
|
} |
||||
|
$oldData = DB::table($oldTableName)->get(); |
||||
|
|
||||
|
$bar = $this->output->createProgressBar(count($oldData)); |
||||
|
$bar->start(); |
||||
|
$newData = []; |
||||
|
foreach ($oldData as $key => $value) { |
||||
|
$newData[] = [ |
||||
|
'id' => $value->id, |
||||
|
'money' => $value->money ?? 0, |
||||
|
'user_id' => $value->user_id ?? 0, |
||||
|
'store_id' => $value->store_id ?? 0, |
||||
|
'market_id' => $value->market_id ?? 0 , |
||||
|
'order_id' => $value->order_id ?? 0, |
||||
|
|
||||
|
'created_at' => $value->createtime ?? 0, |
||||
|
'updated_at' => time(), |
||||
|
]; |
||||
|
|
||||
|
$bar->advance(); |
||||
|
} |
||||
|
|
||||
|
DB::table($newTableName)->insert($newData); |
||||
|
|
||||
|
$bar->finish(); |
||||
|
return 0; |
||||
|
} |
||||
|
} |
||||
@ -1,79 +0,0 @@ |
|||||
<?php |
|
||||
|
|
||||
namespace App\Console\Commands; |
|
||||
|
|
||||
use Illuminate\Console\Command; |
|
||||
use Illuminate\Support\Facades\DB; |
|
||||
use Illuminate\Support\Facades\Schema; |
|
||||
|
|
||||
class MigrateStoreImg extends Command |
|
||||
{ |
|
||||
/** |
|
||||
* The name and signature of the console command. |
|
||||
* |
|
||||
* @var string |
|
||||
*/ |
|
||||
protected $signature = 'migrateData:storeImg'; |
|
||||
|
|
||||
/** |
|
||||
* 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() |
|
||||
{ |
|
||||
|
|
||||
$newTableName = 'lanzu_store_new'; |
|
||||
$storeImgPath = 'QR_code/code_store_img/wx_store_';/* 商户小程序码 */ |
|
||||
$storePayPath = 'QR_code/code_pay_img/wx_pay_';/* 收银二维码 */ |
|
||||
if(!Schema::hasTable($newTableName)){ |
|
||||
var_dump('新表不存在'); |
|
||||
return 0; |
|
||||
} |
|
||||
|
|
||||
$oldData = DB::table($newTableName)->orderBy('id','desc')->get(); |
|
||||
$bar = $this->output->createProgressBar(count($oldData)); |
|
||||
$bar->start(); |
|
||||
$startTime = time(); |
|
||||
$error = []; |
|
||||
$newData = []; |
|
||||
foreach ($oldData as $key => $value){ |
|
||||
$storeId = $value->id; |
|
||||
|
|
||||
$storeData =[ |
|
||||
'store_applet_img' => $storeImgPath.$storeId.'.jpg', |
|
||||
'cash_code_img' => $storePayPath.$storeId.'.jpg', |
|
||||
'updated_at' => time(), |
|
||||
]; |
|
||||
|
|
||||
$newData = $storeData; |
|
||||
$res = DB::table($newTableName)->where('id',$storeId)->update($newData); |
|
||||
if(!$res){ |
|
||||
$error[] = ['id'=>$storeId]; |
|
||||
break; |
|
||||
} |
|
||||
$bar->advance(); |
|
||||
} |
|
||||
$bar->finish(); |
|
||||
var_dump([time()-$startTime]); |
|
||||
var_dump($error); |
|
||||
return 0; |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,16 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Models\v3; |
||||
|
|
||||
|
use Dcat\Admin\Traits\HasDateTimeFormatter; |
||||
|
use Illuminate\Database\Eloquent\SoftDeletes; |
||||
|
use Illuminate\Database\Eloquent\Model; |
||||
|
|
||||
|
class ServicePersonnel extends Model |
||||
|
{ |
||||
|
use HasDateTimeFormatter; |
||||
|
use SoftDeletes; |
||||
|
|
||||
|
protected $table = 'lanzu_service_personnel'; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
<?php |
||||
|
|
||||
|
use Illuminate\Support\Facades\Schema; |
||||
|
use Illuminate\Database\Schema\Blueprint; |
||||
|
use Illuminate\Database\Migrations\Migration; |
||||
|
|
||||
|
class CreateLanzuServicePersonnelTable extends Migration |
||||
|
{ |
||||
|
/** |
||||
|
* Run the migrations. |
||||
|
* |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function up() |
||||
|
{ |
||||
|
Schema::create('lanzu_service_personnel', function (Blueprint $table) { |
||||
|
$table->increments('id'); |
||||
|
$table->unsignedInteger('user_id')->default('0')->comment('服务员懒ID'); |
||||
|
$table->string('name')->default('')->comment('姓名'); |
||||
|
$table->char('tel')->comment('电话'); |
||||
|
$table->tinyInteger('market_id')->default('0')->comment('所属市场'); |
||||
|
$table->tinyInteger('type')->default('0')->comment('类型'); |
||||
|
$table->tinyInteger('status')->default('0')->comment('状态'); |
||||
|
$table->string('qr_url')->default('0')->comment('专员二维码'); |
||||
|
$table->string('head_url')->default('0')->comment('头像'); |
||||
|
$table->timestamps(); |
||||
|
$table->softDeletes(); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Reverse the migrations. |
||||
|
* |
||||
|
* @return void |
||||
|
*/ |
||||
|
public function down() |
||||
|
{ |
||||
|
Schema::dropIfExists('lanzu_service_personnel'); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
<?php |
||||
|
return [ |
||||
|
'labels' => [ |
||||
|
'ServicePersonnel' => '服务站专员', |
||||
|
'servicePersonnel' => '服务站专员', |
||||
|
'service_personnel' => '服务站专员', |
||||
|
], |
||||
|
'fields' => [ |
||||
|
'user_id' => '服务员懒ID', |
||||
|
'name' => '姓名', |
||||
|
'tel' => '电话', |
||||
|
'market_id' => '所属市场', |
||||
|
'type' => '类型', |
||||
|
'type_text' => '类型', |
||||
|
'status' => '状态', |
||||
|
'status_text' => '状态', |
||||
|
'qr_url' => '专员二维码', |
||||
|
'head_url' => '头像', |
||||
|
], |
||||
|
'options' => [ |
||||
|
], |
||||
|
]; |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue