Browse Source

Merge branch 'phoenix' into develop

master
liangyuyan 5 years ago
parent
commit
3e8b75ac52
  1. 36
      app/Admin/Actions/Grid/v3/StoreSetTime.php
  2. 2
      app/Admin/Controllers/v3/BannersController.php
  3. 52
      app/Admin/Controllers/v3/GoodsActivityController.php
  4. 31
      app/Admin/Controllers/v3/GoodsController.php
  5. 26
      app/Admin/Controllers/v3/GoodsNewController.php
  6. 86
      app/Admin/Controllers/v3/ServicePersonnelController.php
  7. 2
      app/Admin/Controllers/v3/StoreController.php
  8. 3
      app/Admin/Forms/GoodsCopyForm.php
  9. 3
      app/Admin/Forms/GoodsNewCopyForm.php
  10. 3
      app/Admin/Forms/GoodsNewImageForm.php
  11. 65
      app/Admin/Forms/v3/StoreSetTimeForm.php
  12. 16
      app/Admin/Repositories/v3/ServicePersonnel.php
  13. 3
      app/Admin/routes.php
  14. 139
      app/Console/Commands/MigrateCoupon.php
  15. 89
      app/Console/Commands/MigrateCouponReceive.php
  16. 84
      app/Console/Commands/MigrateCouponUse.php
  17. 16
      app/Console/Commands/MigrateFePrint.php
  18. 4
      app/Console/Commands/MigrateMarketData.php
  19. 14
      app/Console/Commands/MigrateOrder.php
  20. 79
      app/Console/Commands/MigrateOrderStatistics.php
  21. 21
      app/Console/Commands/MigrateStoreBalance.php
  22. 4
      app/Console/Commands/MigrateStoreFinancial.php
  23. 79
      app/Console/Commands/MigrateStoreImg.php
  24. 2
      app/Console/Commands/MigrateUserAddr.php
  25. 3
      app/Models/v3/GoodsActivity.php
  26. 16
      app/Models/v3/ServicePersonnel.php
  27. 40
      database/migrations/2020_09_14_120733_create_lanzu_service_personnel_table.php
  28. 4
      dcat_admin_ide_helper.php
  29. 3
      resources/lang/zh-CN/goods-activity.php
  30. 22
      resources/lang/zh-CN/service-personnel.php

36
app/Admin/Actions/Grid/v3/StoreSetTime.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 [
];
}
}

2
app/Admin/Controllers/v3/BannersController.php

@ -105,7 +105,7 @@ class BannersController extends AdminController
});
});
$form->column(6, function (Form $form) {
$form->image('cover')->required()->uniqueName();//->disk('admin')
$form->image('cover')->required()->uniqueName();
$form->select('cover_type')->options(BannersModel::$_coverType)->required();
$form->text('path')->default('');
$form->select('path_type')->options(BannersModel::$_pathType)->default('');

52
app/Admin/Controllers/v3/GoodsActivityController.php

@ -132,20 +132,19 @@ class GoodsActivityController extends AdminController
// 店铺
$storeList = StoreModel::getStoreArray();
//市场
// $marketList = MarketModel::getMarketArray();
$marketList = MarketModel::getMarketArray();
$form->column(6, function (Form $form) use($storeList,$categoryList ){
$form->column(6, function (Form $form) use($marketList,$storeList,$categoryList ){
$form->text('goods_id')->default(0)->help('输入正常商品id,用于关联商品。');
$form->hidden('market_id')->default(0);
$form->multipleSelect('market_ids')->options($marketList)->help('不选则适用所有市场');
$form->select('category_id')->required()->options($categoryList)->load('goods_category_id', '/api/goods_category_list');
$form->select('goods_category_id');
$form->select('store_id')->required()->options($storeList);
$form->text('name')->required()->maxLength(20);
$form->image('cover_img')->required()->uniqueName();
$form->select('type')->options(GoodsActivityModel::$_type)->default('flash_sale');
$form->datetime('expire_time')->value($form->model()->expire_time_text);
$form->number('time_limit_days');
$form->datetime('expire_time')->required()->format('YYYY-MM-DD HH:mm:ss')->help($form->model()->expire_time_text);
});
$form->column(6, function (Form $form) {
$form->currency('price')->required()->floatTwo()->symbol('¥');
@ -154,9 +153,10 @@ class GoodsActivityController extends AdminController
$form->text('goods_unit')->help('如:斤,个,盒,500克,1000克,1500克等');
$form->radio('is_infinite')->options(['关闭','开启'])->default(1);
$form->number('inventory')->required()->attribute('min', 1)->default(1);
$form->number('restrict_num')->attribute('min', 0)->default(0)->help('0表示不限购');
$form->number('restrict_num')->attribute('min', 0)->default(0)->help('0表示不限购,单笔订单限购数量');
$form->number('start_num')->attribute('min', 1)->default(1);
$form->number('time_limit_num');
$form->number('time_limit_days')->help('A时间段内限购');
$form->number('time_limit_num')->help('A时间段内限购的数量');
$form->switch('can_use_coupon');
});
$form->column(12, function (Form $form) {
@ -191,11 +191,49 @@ class GoodsActivityController extends AdminController
});
$form->saving(function (Form $form){
$storeId = $form->input('store_id');
$marketIds = $form->input('market_ids');
$tags = $form->input('tags');
$spec = $form->input('spec');
$detailsImgs = $form->input('details_imgs');
$goodsCategoryId = $form->input('goods_category_id');
if(!empty($storeId)){
// 商品所属市场,根据店铺查询市场
$info = StoreModel::getStoreInfo($storeId,'market_id');
$form->market_id = $info->market_id;
}
$marketIdsArr = [];
if(!empty($marketIds)){
foreach($marketIds as $km => $marketId){
if(empty($marketId)){
unset($marketIds[$km]);
continue;
}
$marketIdsArr[] = $marketId;
}
}
$form->marketIds = json_encode($marketIdsArr);
$tagsArr = [];
if(!empty($tags)){
foreach($tags as $kt => $tag){
if(empty($tag)){
unset($tags[$kt]);
continue;
}
$tagsArr[] = $tag;
}
};
$form->tags = json_encode($tagsArr);
if($storeId && empty($spec)){
$form->spec = [];
}
if($storeId && empty($detailsImgs)){
$form->details_imgs = [];
}
if($storeId && empty($goodsCategoryId)){
$form->goods_category_id = 0;
}
});
$form->disableResetButton();
$form->disableViewCheck();

31
app/Admin/Controllers/v3/GoodsController.php

@ -12,6 +12,7 @@ use App\Models\v3\Category as CategoryModel;
use App\Models\v3\Store as StoreModel;
use Dcat\Admin\Form\NestedForm;
use App\Models\v3\Goods as GoodsModel;
use App\Models\v3\GoodsBanners as GoodsBannersModel;
use App\Models\v3\Market as MarketModel;
use Dcat\Admin\Grid\Displayers\Actions;
use App\Models\v3\GoodsCategory as GoodsCategoryModel;
@ -82,12 +83,12 @@ class GoodsController extends AdminController
return empty($item) ? '' : $item->title;
});
$show->width(6)->store_id->as(function ($storeId){
$item = GoodsCategoryModel::getInfo($storeId,'name');
$item = storeModel::getStoreInfo($storeId,'name');
return empty($item) ? '' : $item->name;
});
$show->width(6)->store_id->as(function ($goodsCategoryId){
$item = StoreModel::getStoreInfo($goodsCategoryId,'name');
return empty($item) ? '' : $item->name;
$show->width(6)->goods_category_id->as(function ($goodsCategoryId){
$item = GoodsCategoryModel::getInfo($goodsCategoryId,'title');
return empty($item) ? '' : $item->title;
});
$show->width(6)->cover_img->image();
$show->width(6)->price;
@ -110,9 +111,11 @@ class GoodsController extends AdminController
});
$show->width(6)->spec->as(function ($value){
$text = '';
if($value){
foreach ($value as $v){
$text .= '【'.$v['spec_key'] .':'.$v['spec_value'].'】 ';
}
}
return $text;
});
$goodsModel = new GoodsModel();
@ -179,7 +182,7 @@ class GoodsController extends AdminController
});
$form->column(12, function (Form $form) {
$form->hasMany('image_banners', function (Form\NestedForm $form) {
$form->image('path')->width(2)->uniqueName();
$form->image('path')->required()->width(2)->uniqueName();
$form->number('sort')->width(2)->default(0);
$form->hidden('type')->value(1)->default(1);
})->required();
@ -214,15 +217,21 @@ class GoodsController extends AdminController
$form->disableCreatingCheck();
});
$form->saving(function (Form $form){
$id = $form->getKey;
$storeId = $form->input('store_id');
$tags = $form->input('tags');
$spec = $form->input('spec');
$detailsImgs = $form->input('details_imgs');
$goodsCategoryId = $form->input('goods_category_id');
if(!empty($storeId)){
// 商品所属市场,根据店铺查询市场
$info = StoreModel::getStoreInfo($storeId,'market_id');
$form->market_id = $info->market_id;
}
$tags = $form->input('tags');
$tagsArr = [];
if(!empty($tags)){
foreach($tags as $kt => $tag){
if(empty($tag)){
unset($tags[$kt]);
@ -230,7 +239,17 @@ class GoodsController extends AdminController
}
$tagsArr[] = $tag;
}
};
$form->tags = json_encode($tagsArr);
if($storeId && empty($spec)){
$form->spec = [];
}
if($storeId && empty($detailsImgs)){
$form->details_imgs = [];
}
if($storeId && empty($goodsCategoryId)){
$form->goods_category_id = 0;
}
});
});
}

26
app/Admin/Controllers/v3/GoodsNewController.php

@ -99,12 +99,12 @@ class GoodsNewController extends AdminController
return empty($item) ? '' : $item->title;
});
$show->width(6)->store_id->as(function ($storeId){
$item = GoodsCategoryModel::getInfo($storeId,'name');
$item = StoreModel::getStoreInfo($storeId,'name');
return empty($item) ? '' : $item->name;
});
$show->width(6)->store_id->as(function ($goodsCategoryId){
$item = StoreModel::getStoreInfo($goodsCategoryId,'name');
return empty($item) ? '' : $item->name;
$show->width(6)->goods_category_id->as(function ($goodsCategoryId){
$item = GoodsCategoryModel::getInfo($goodsCategoryId,'title');
return empty($item) ? '' : $item->title;
});
$show->width(6)->cover_img->image();
$show->width(6)->price;
@ -127,9 +127,11 @@ class GoodsNewController extends AdminController
});
$show->width(6)->spec->as(function ($value){
$text = '';
if($value){
foreach ($value as $v){
$text .= '【'.$v['spec_key'] .':'.$v['spec_value'].'】 ';
}
}
return $text;
});
$goodsModel = new GoodsModel();
@ -231,8 +233,12 @@ class GoodsNewController extends AdminController
$form->disableCreatingCheck();
});
$form->saving(function (Form $form){
// $storeId = $form->input('store_id');
$storeId = $form->input('store_id');
$tags = $form->input('tags');
$spec = $form->input('spec');
$detailsImgs = $form->input('details_imgs');
$goodsCategoryId = $form->input('goods_category_id');
// 商品所属市场,根据店铺查询市场
// $info = StoreModel::getStoreInfo($storeId,'market_id');
// $form->market_id = $info->market_id;
@ -250,6 +256,16 @@ class GoodsNewController extends AdminController
$form->tags = json_encode($tagsArr);
}
if($storeId && empty($spec)){
$form->spec = [];
}
if($storeId && empty($detailsImgs)){
$form->details_imgs = [];
}
if($storeId && empty($goodsCategoryId)){
$form->goods_category_id = 0;
}
});
});
}

86
app/Admin/Controllers/v3/ServicePersonnelController.php

@ -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');
});
}
}

2
app/Admin/Controllers/v3/StoreController.php

@ -15,6 +15,7 @@ use App\Models\v3\User as UserModel;
use App\Models\v3\Category as CategoryModel;
use App\Models\LanzuUserBalance as UserBalanceModel;
use App\Models\v3\StoreUsers as StoreUsersModel;
use App\Admin\Actions\Grid\v3\StoreSetTime;
class StoreController extends AdminController
{
@ -46,6 +47,7 @@ class StoreController extends AdminController
$grid->is_rest->switch();
$grid->is_open->switch();
$grid->actions([new StoreSetTime()]);
// 搜索
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('id');

3
app/Admin/Forms/GoodsCopyForm.php

@ -87,7 +87,8 @@ class GoodsCopyForm extends Form
$id = $this->getKey();
$goods = GoodsModel::select('name')->find($id);
$this->hidden('goods_id')->value($id);
$this->display('name')->value($goods->name);
$name = empty($goods->name)?'':$goods->name;
$this->display('name')->value($name);
$stores = StoreModel::getStoreArray();
$this->multipleSelect('store_ids','选择店铺')->required()->options($stores)->help('选择店铺,将当前商品复制到所选店铺。注意选择重复店铺问题!!!');
}

3
app/Admin/Forms/GoodsNewCopyForm.php

@ -87,7 +87,8 @@ class GoodsNewCopyForm extends Form
$id = $this->getKey();
$goods = GoodsModel::select('name')->find($id);
$this->hidden('goods_id')->value($id);
$this->display('name')->value($goods->name);
$name = empty($goods->name)?'':$goods->name;
$this->display('name')->value($name);
$stores = StoreModel::getStoreArray();
$this->multipleSelect('store_ids','选择店铺')->required()->options($stores)->help('选择店铺,将当前商品复制到所选店铺。注意选择重复店铺问题!!!');
}

3
app/Admin/Forms/GoodsNewImageForm.php

@ -55,7 +55,8 @@ class GoodsNewImageForm extends Form
$goods = GoodsModel::select('name')->find($id);
$goodName = empty($goods->name)?'':$goods->name;
$this->hidden('goods_id')->value($id);
$this->image('cover_img','封面图')->url('ops/files')->help('商品名称:'.$goodName);
$this->display('name','商品名称')->value($goodName);
$this->image('cover_img','封面图')->url('ops/files');
$this->image('img_banner','轮播图')->url('ops/files');
}

65
app/Admin/Forms/v3/StoreSetTimeForm.php

@ -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 [];
}
}

16
app/Admin/Repositories/v3/ServicePersonnel.php

@ -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;
}

3
app/Admin/routes.php

@ -69,5 +69,8 @@ Route::group([
$router->resource('/horseman', 'LanzuServiceHorsemanController');
$router->any('ops/files', 'v3\FileController@handle');
// 服务站专员
$router->resource('/service_personnel', 'v3\ServicePersonnelController');
});

139
app/Console/Commands/MigrateCoupon.php

@ -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;
}
}

89
app/Console/Commands/MigrateCouponReceive.php

@ -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;
}
}

84
app/Console/Commands/MigrateCouponUse.php

@ -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;
}
}

16
app/Console/Commands/MigrateFePrint.php

@ -40,7 +40,7 @@ class MigrateFePrint extends Command
public function handle()
{
$oldTableName = 'ims_cjdc_feprint';
$newTableName = 'lanzu_feprint_copy';
$newTableName = 'lanzu_feprint';
// 判断表是否存在
if(!Schema::hasTable($oldTableName)){
var_dump('旧表不存在');
@ -58,14 +58,14 @@ class MigrateFePrint extends Command
foreach ($oldData as $key => $value) {
$newData[] = [
'id' => $value->id,
'name' => $value->name,
'sn' => $value->sn,
'market_id' => $value->market_id ,
'simnum' => $value->simnum,
'addtime' => $value->addtime,
'status' => $value->status,
'name' => $value->name ?? '',
'sn' => $value->sn ?? '',
'market_id' => $value->market_id ?? 0,
'simnum' => $value->simnum ?? 0 ,
'addtime' => $value->addtime ?? 0,
'status' => $value->status ?? 0,
'created_at' => strtotime($value->addtime),
'created_at' => $value->addtime ? strtotime($value->addtime) : 0,
'updated_at' => time(),
];

4
app/Console/Commands/MigrateMarketData.php

@ -40,7 +40,7 @@ class MigrateMarketData extends Command
{
// get old data from old table
$oldData = DB::table('ims_cjdc_market_new')->get();
$oldData = DB::table('ims_cjdc_market')->get();
$bar = $this->output->createProgressBar(count($oldData));
$bar->start();
@ -65,7 +65,7 @@ class MigrateMarketData extends Command
'status' => $value->status ?? 1,
'sort' => $value->sort ?? 1,
'created_at' => $value->addtime ? strtotime($value->addtime) : 0,
'updated_at' => $value->addtime ? strtotime($value->addtime) : 0,
'updated_at' => time(),
];
$bar->advance();

14
app/Console/Commands/MigrateOrder.php

@ -52,7 +52,7 @@ class MigrateOrder extends Command
$dataMain = [
'market_id' => $main->market_id ?? 0,
'order_num' => $main->order_num ?? '',
'global_order_id' => $main->global_order_id ?? 0,
'global_order_id' => $main->global_order_id ?? time().mt_rand(100000,999999),
'user_id' => $main->user_id ?? 0,
'pay_type' => $main->pay_type ?? 0,
'type' => $main->type ?? 0,
@ -81,8 +81,13 @@ class MigrateOrder extends Command
'delivery_time_note' => $main->delivery_time ?? '',
'total_refund_note' => $main->total_refund_note ?? '',
'note' => $main->note ?? '',
'shipping_name' => $main->shipping_name ?? '',
'horseman_id' => $main->horseman_id ?? 0,
'delivery_distance' => $main->delivery_distance ?? 0,
'created_at' => $main->time_add ?? 0,
'updated_at' => 0,
'updated_at' => time(),
];
$newMainId = DB::table('lanzu_order_main')->insertGetId($dataMain);
@ -91,7 +96,7 @@ class MigrateOrder extends Command
foreach ($orderChildren as $kChild => $child) {
// 子订单
$dataChild = [
'order_main_id' => $newMainId ?? 0,
'order_main_id' => $dataMain['global_order_id'] ?? 0,
'user_id' => $child->user_id ?? 0,
'store_id' => $child->store_id ?? 0,
'status' => 1,
@ -103,7 +108,7 @@ class MigrateOrder extends Command
'refund_note' => '',
'note' => $child->note ?? '',
'created_at' => $child->time_add ? strtotime($child->time_add) : 0,
'updated_at' => $child->time_add ? strtotime($child->time_add) : 0,
'updated_at' => time(),
];
$newChildId = DB::table('lanzu_order')->insertGetId($dataChild);
@ -128,6 +133,7 @@ class MigrateOrder extends Command
'created_at' => time(),
'updated_at' => time(),
'refuse_refund_note' => '',
'note' => '',
];
}
DB::table('lanzu_order_goods')->insert($dataGoods);

79
app/Console/Commands/MigrateOrderStatistics.php

@ -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;
}
}

21
app/Console/Commands/MigrateStoreBalance.php

@ -70,16 +70,15 @@ class MigrateStoreBalance extends Command
foreach($newData as $store_id => $money){
$exist = DB::table($newBalanceTableName)->where('source_id',$store_id)->where('user_type',5)->exists();
if($exist){
$saveData = [
'balance' => number_format($money,2,'.',''),
'updated_at' => time()
];
// var_dump($saveData);
// return 0;
$res = DB::table($newBalanceTableName)->where('source_id',$store_id)->where('user_type',5)->update($saveData);
if(!$res){
$error[] = ['store_id'=>$store_id,'money'=>$money];
}
$error[] = ['store_id'=>$store_id,'money'=>$money,'msg'=>'已存在'];
// $saveData = [
// 'balance' => number_format($money,2,'.',''),
// 'updated_at' => time()
// ];
// $res = DB::table($newBalanceTableName)->where('source_id',$store_id)->where('user_type',5)->increment('balance',$saveData['balance']);
// if(!$res){
// $error[] = ['store_id'=>$store_id,'money'=>$money];
// }
}else{
$saveData = [
'source_id' => $store_id,
@ -87,8 +86,6 @@ class MigrateStoreBalance extends Command
'balance' => number_format($money,2,'.',''),
'updated_at' => time()
];
// var_dump($saveData);
// return 0;
$res = DB::table($newBalanceTableName)->insert($saveData);
if(!$res){
$error[] = ['store_id'=>$store_id,'money'=>$money];

4
app/Console/Commands/MigrateStoreAccount.php → app/Console/Commands/MigrateStoreFinancial.php

@ -6,14 +6,14 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class MigrateStoreAccount extends Command
class MigrateStoreFinancial extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'migrateData:storeAccount';
protected $signature = 'migrateData:storeFinancial';
/**
* The console command description.

79
app/Console/Commands/MigrateStoreImg.php

@ -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;
}
}

2
app/Console/Commands/MigrateUserAddr.php

@ -74,7 +74,7 @@ class MigrateUserAddr extends Command
'tel' => $value->tel == 'undefined'? '': $value->tel,
'doorplate' => $doorplate,
'is_default' => $value->is_default ?? 0,
'tags' => json_encode(''),
'tags' => json_encode([]),
'created_at' => time(),
'updated_at' => time(),
];

3
app/Models/v3/GoodsActivity.php

@ -23,7 +23,8 @@ class GoodsActivity extends Model
protected $casts = [
'details_imgs'=>'array',
'tags'=>'array',
// 'tags'=>'array',
// 'market_ids'=>'array',
'spec'=>'array',
];

16
app/Models/v3/ServicePersonnel.php

@ -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';
}

40
database/migrations/2020_09_14_120733_create_lanzu_service_personnel_table.php

@ -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');
}
}

4
dcat_admin_ide_helper.php

@ -1205,6 +1205,7 @@ namespace Dcat\Admin {
* @property Grid\Column|Collection services_money
* @property Grid\Column|Collection coupon_money
* @property Grid\Column|Collection delivery_money
* @property Grid\Column|Collection delivery_distance
* @property Grid\Column|Collection horseman_id
* @property Grid\Column|Collection delivery_time_note
* @property Grid\Column|Collection total_refund_note
@ -2432,6 +2433,7 @@ namespace Dcat\Admin {
* @method Grid\Column|Collection services_money(string $label = null)
* @method Grid\Column|Collection coupon_money(string $label = null)
* @method Grid\Column|Collection delivery_money(string $label = null)
* @method Grid\Column|Collection delivery_distance(string $label = null)
* @method Grid\Column|Collection horseman_id(string $label = null)
* @method Grid\Column|Collection delivery_time_note(string $label = null)
* @method Grid\Column|Collection total_refund_note(string $label = null)
@ -3664,6 +3666,7 @@ namespace Dcat\Admin {
* @property Show\Field|Collection services_money
* @property Show\Field|Collection coupon_money
* @property Show\Field|Collection delivery_money
* @property Show\Field|Collection delivery_distance
* @property Show\Field|Collection horseman_id
* @property Show\Field|Collection delivery_time_note
* @property Show\Field|Collection total_refund_note
@ -4891,6 +4894,7 @@ namespace Dcat\Admin {
* @method Show\Field|Collection services_money(string $label = null)
* @method Show\Field|Collection coupon_money(string $label = null)
* @method Show\Field|Collection delivery_money(string $label = null)
* @method Show\Field|Collection delivery_distance(string $label = null)
* @method Show\Field|Collection horseman_id(string $label = null)
* @method Show\Field|Collection delivery_time_note(string $label = null)
* @method Show\Field|Collection total_refund_note(string $label = null)

3
resources/lang/zh-CN/goods-activity.php

@ -9,7 +9,8 @@ return [
'type' => '活动类型',
'type_text' => '活动类型',
'goods_id' => '原始商品',
'market_id' => '市场',
'market_id' => '所属市场',
'market_ids' => '适用市场',
'store_id' => '商家',
'category_id' => '分类',
'goods_category_id' => '商品类目',

22
resources/lang/zh-CN/service-personnel.php

@ -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' => [
],
];
Loading…
Cancel
Save