16 changed files with 679 additions and 18 deletions
-
106app/Admin/Controllers/GoodsController.php
-
162app/Admin/Controllers/StoreController.php
-
16app/Admin/Repositories/Goods.php
-
16app/Admin/Repositories/Store.php
-
6app/Admin/routes.php
-
21app/Models/Goods.php
-
15app/Models/ImsCjdcMarket.php
-
19app/Models/LanzuMmInfo.php
-
92app/Models/Store.php
-
33app/Models/StoreType.php
-
9app/Models/TypeCorrelation.php
-
59database/migrations/2020_09_01_094230_create_lanzu_store_table.php
-
50database/migrations/2020_09_01_095556_create_lanzu_goods_table.php
-
24dcat_admin_ide_helper.php
-
28resources/lang/zh-CN/goods.php
-
41resources/lang/zh-CN/store.php
@ -0,0 +1,106 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers; |
|||
|
|||
use App\Admin\Repositories\Goods; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
|
|||
class GoodsController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new Goods(), function (Grid $grid) { |
|||
$grid->id->sortable(); |
|||
$grid->cover_img; |
|||
$grid->name; |
|||
$grid->type_id; |
|||
$grid->store_id; |
|||
|
|||
$grid->price; |
|||
|
|||
|
|||
$grid->sort; |
|||
$grid->on_sale; |
|||
|
|||
$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 Goods(), function (Show $show) { |
|||
$show->id; |
|||
$show->name; |
|||
$show->type_id; |
|||
$show->store_id; |
|||
$show->cover_img; |
|||
$show->price; |
|||
$show->original_price; |
|||
$show->vip_price; |
|||
$show->on_sale; |
|||
$show->inventory; |
|||
$show->content; |
|||
$show->sort; |
|||
$show->restrict_num; |
|||
$show->start_num; |
|||
$show->is_infinite; |
|||
$show->good_unit; |
|||
$show->tags; |
|||
$show->details_imgs; |
|||
$show->spec; |
|||
$show->created_at; |
|||
$show->updated_at; |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new Goods(), function (Form $form) { |
|||
$form->display('id'); |
|||
$form->text('name'); |
|||
$form->text('type_id'); |
|||
$form->text('store_id'); |
|||
$form->text('cover_img'); |
|||
$form->text('price'); |
|||
$form->text('original_price'); |
|||
$form->text('vip_price'); |
|||
$form->text('on_sale'); |
|||
$form->text('inventory'); |
|||
$form->text('content'); |
|||
$form->text('sort'); |
|||
$form->text('restrict_num'); |
|||
$form->text('start_num'); |
|||
$form->text('is_infinite'); |
|||
$form->text('good_unit'); |
|||
$form->text('tags'); |
|||
$form->text('details_imgs'); |
|||
$form->text('spec'); |
|||
|
|||
$form->display('created_at'); |
|||
$form->display('updated_at'); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,162 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers; |
|||
|
|||
use App\Admin\Repositories\Store; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use App\Models\StoreType as StoreTypeModel; |
|||
use App\Models\LanzuMmInfo as MminfoModel; |
|||
use App\Models\ImsCjdcMarket as MarketModel; |
|||
|
|||
class StoreController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
// $m = StoreModel::find(1);
|
|||
// dd($m->market_name);
|
|||
return Grid::make(new Store(), function (Grid $grid) { |
|||
$grid->model()->orderBy('id','desc'); |
|||
$grid->id->sortable(); |
|||
$grid->logo_url->image('',50); |
|||
$grid->name; |
|||
|
|||
$grid->market_name; |
|||
$grid->mm_user_id; |
|||
$grid->store_type_name; |
|||
|
|||
$grid->sort->sortable(); |
|||
$grid->is_rest->switch(); |
|||
$grid->is_open->switch(); |
|||
|
|||
// 每页10条
|
|||
$grid->paginate(10); |
|||
|
|||
// 搜索
|
|||
$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 Store(), function (Show $show) { |
|||
$show->id; |
|||
$show->mm_user_id; |
|||
$show->market_id; |
|||
$show->name; |
|||
$show->address; |
|||
|
|||
$show->tel; |
|||
$show->announcement; |
|||
$show->is_rest; |
|||
$show->logo; |
|||
$show->details; |
|||
$show->coordinates; |
|||
$show->business_license; |
|||
$show->store_type_id; |
|||
$show->is_open; |
|||
$show->sort; |
|||
$show->user_id; |
|||
$show->environment; |
|||
$show->expire_time; |
|||
$show->zm_img; |
|||
$show->fm_img; |
|||
$show->link_name; |
|||
$show->link_tel; |
|||
$show->admin_id; |
|||
$show->loudspeaker_imei; |
|||
|
|||
$show->time; |
|||
$show->time2; |
|||
$show->time3; |
|||
$show->time4; |
|||
|
|||
$show->created_at; |
|||
$show->updated_at; |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new Store(), function (Form $form) { |
|||
// 查询市场经理
|
|||
$mmList = MminfoModel::getMmInfoArray(); |
|||
// 查询市场
|
|||
$marketList = MarketModel::getMarket(); |
|||
// 查询一级分类(店铺分类)
|
|||
$storeTypeList = StoreTypeModel::getStoreTypeArray(); |
|||
|
|||
$form->hidden('id'); |
|||
$form->select('mm_user_id')->width(4)->required()->options($mmList); |
|||
$form->select('market_id')->width(4)->required()->options($marketList); |
|||
$form->select('store_type_id')->width(4)->required()->options($storeTypeList); |
|||
|
|||
$form->text('name')->width(3)->required(); |
|||
$form->image('logo')->width(2)->required(); |
|||
|
|||
$form->mobile('tel')->width(2); |
|||
$form->text('link_name')->width(2)->required(); |
|||
$form->mobile('link_tel')->width(2)->required(); |
|||
$form->text('address')->width(8); |
|||
$form->text('coordinates')->width(4) |
|||
->placeholder('输入 经纬度,如: 108.281552,22.83731') |
|||
->help("通过网址 <a href='https://lbs.amap.com/console/show/picker' target='_blank'>https://lbs.amap.com/console/show/picker</a> 获取经纬度"); |
|||
$form->image('business_license')->width(2)->required(); |
|||
$form->image('zm_img')->width(2)->required(); |
|||
$form->image('fm_img')->width(2)->required(); |
|||
$form->text('admin_id')->width(2)->required(); |
|||
$form->text('user_id')->width(2)->required(); |
|||
|
|||
// $form->text('coordinates');
|
|||
$form->textarea('introduction')->required(); |
|||
$form->textarea('announcement'); |
|||
$form->multipleImage('environment'); |
|||
|
|||
// $form->text('expire_time');
|
|||
// $form->text('loudspeaker_imei');
|
|||
// $form->switch('is_rest');
|
|||
$form->timeRange('time1','time2','营业时间段一')->required(); |
|||
$form->timeRange('time3','time4','营业时间段二'); |
|||
|
|||
$form->number('sort')->width(2); |
|||
// $form->switch('is_open');
|
|||
|
|||
$form->saving(function (Form $form){ |
|||
// 修改是否休息 1-》1 =,0=》2
|
|||
// $isOpen = $form->is_open;
|
|||
}); |
|||
$form->saved(function (Form $form){ |
|||
|
|||
if($form->isCreating()){ |
|||
// 生产二维码
|
|||
|
|||
} |
|||
|
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Repositories; |
|||
|
|||
use App\Models\Goods as Model; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class Goods extends EloquentRepository |
|||
{ |
|||
/** |
|||
* Model. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $eloquentClass = Model::class; |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Repositories; |
|||
|
|||
use App\Models\Store as Model; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class Store extends EloquentRepository |
|||
{ |
|||
/** |
|||
* Model. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $eloquentClass = Model::class; |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
<?php |
|||
|
|||
namespace App\Models; |
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use Illuminate\Database\Eloquent\SoftDeletes; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class Goods extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
use SoftDeletes; |
|||
|
|||
protected $table = 'lanzu_goods'; |
|||
protected $dateFormat = 'U'; |
|||
protected $appends = [ |
|||
'cover_img_url', |
|||
'market_name', |
|||
'goods_type_name' |
|||
]; |
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
<?php |
|||
|
|||
namespace App\Models; |
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use Illuminate\Database\Eloquent\SoftDeletes; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use App\Models\ImsCjdcMarket as MarketModel; |
|||
use App\Models\StoreType as StoreTypeModel; |
|||
|
|||
class Store extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
use SoftDeletes; |
|||
|
|||
protected $table = 'lanzu_store'; |
|||
protected $dateFormat = 'U'; |
|||
|
|||
protected $appends = [ |
|||
'logo_url', |
|||
'market_name', |
|||
'store_type_name' |
|||
]; |
|||
|
|||
public function getMarketNameAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->market_id; |
|||
$market = MarketModel::getMarketInfo($value,'name'); |
|||
return $market ? $market->name : ''; |
|||
} |
|||
public function getStoreTypeNameAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->store_type_id; |
|||
$storeType = StoreTypeModel::getStoreTypeInfo($value,'type_name'); |
|||
return $storeType ? $storeType->type_name : ''; |
|||
} |
|||
|
|||
public function getLogoUrlAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->logo; |
|||
return $this->imageUrl($value); |
|||
} |
|||
|
|||
/** |
|||
* 获取商家环境图片 |
|||
* @param $value $this->environment |
|||
* @return array |
|||
*/ |
|||
public function getEnvironmentAttribute($value) |
|||
{ |
|||
$value = $value ? $value : ''; |
|||
return $value ? explode(',',$value) : []; |
|||
} |
|||
public function setEnvironmentAttribute($value) |
|||
{ |
|||
$this->attributes['environment'] = implode(',',$value); |
|||
} |
|||
|
|||
/** |
|||
* 是否开启店铺 |
|||
*/ |
|||
public function getIsOpenAttribute($value) |
|||
{ |
|||
$value = $value ? $value : ''; |
|||
return $value ? explode(',',$value) : []; |
|||
} |
|||
public function setIsOpenAttribute($value) |
|||
{ |
|||
$this->attributes['IsOpen'] = 1; |
|||
} |
|||
|
|||
/** |
|||
* 获取单个店铺信息 |
|||
* @param int $id |
|||
* @param string $field |
|||
* @return string |
|||
*/ |
|||
public static function getStoreInfo($id,$field = '*') |
|||
{ |
|||
return self::select($field)->find($id); |
|||
} |
|||
|
|||
// 处理图片
|
|||
public function imageUrl($value) |
|||
{ |
|||
if(strripos($value,"http") === false){ |
|||
return env('OSS_IMG_HOST').'/'.$value; |
|||
}else{ |
|||
return $value; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
<?php |
|||
|
|||
use Illuminate\Support\Facades\Schema; |
|||
use Illuminate\Database\Schema\Blueprint; |
|||
use Illuminate\Database\Migrations\Migration; |
|||
|
|||
class CreateLanzuStoreTable extends Migration |
|||
{ |
|||
/** |
|||
* Run the migrations. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function up() |
|||
{ |
|||
Schema::create('lanzu_store', function (Blueprint $table) { |
|||
$table->increments('id'); |
|||
$table->integer('market_id')->default('0')->comment('所属市场'); |
|||
$table->string('name')->default('')->comment('商家名称'); |
|||
$table->string('address')->default('')->comment('商家地址'); |
|||
$table->string('time')->default('')->comment('营业时间'); |
|||
$table->string('time2')->default('')->comment('营业时间'); |
|||
$table->string('time3')->nullable()->comment('营业时间'); |
|||
$table->string('time4')->nullable()->comment('营业时间'); |
|||
$table->string('tel')->default('')->comment('电话(座机)'); |
|||
$table->string('announcement')->nullable()->comment('公告'); |
|||
$table->integer('is_rest')->default('2')->comment('是否休息'); |
|||
$table->string('logo')->default('')->comment('logo'); |
|||
$table->text('details')->comment('商家简介'); |
|||
$table->string('coordinates')->default('')->comment('经纬度'); |
|||
$table->text('business_license')->comment('营业资质'); |
|||
$table->integer('store_type_id')->default('0')->comment('店铺所属分类'); |
|||
$table->integer('is_open')->default('1')->comment('是否开启门店'); |
|||
$table->integer('sort')->default('0')->comment('排序'); |
|||
$table->integer('user_id')->default('0')->comment('提现用户id'); |
|||
$table->text('environment')->nullable()->comment('商家环境'); |
|||
$table->string('expire_time')->nullable()->comment('到期时间'); |
|||
$table->string('zm_img')->default('')->comment('身份证正面'); |
|||
$table->string('fm_img')->default('')->comment('身份证反面'); |
|||
$table->string('link_name')->default('')->comment('联系人姓名'); |
|||
$table->string('link_tel')->default('')->comment('电话号码(手机)'); |
|||
$table->integer('admin_id')->default('0')->comment('管理员'); |
|||
$table->char('loudspeaker_imei')->nullable()->comment('喇叭终端的机器码IMEI码'); |
|||
$table->bigInteger('mm_user_id')->default('0')->comment('所属市场经理ID'); |
|||
$table->timestamps(); |
|||
$table->softDeletes(); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Reverse the migrations. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function down() |
|||
{ |
|||
Schema::dropIfExists('lanzu_store'); |
|||
} |
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
<?php |
|||
|
|||
use Illuminate\Support\Facades\Schema; |
|||
use Illuminate\Database\Schema\Blueprint; |
|||
use Illuminate\Database\Migrations\Migration; |
|||
|
|||
class CreateLanzuGoodsTable extends Migration |
|||
{ |
|||
/** |
|||
* Run the migrations. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function up() |
|||
{ |
|||
Schema::create('lanzu_goods', function (Blueprint $table) { |
|||
$table->increments('id'); |
|||
$table->string('name')->default('')->comment('商品名称'); |
|||
$table->integer('type_id')->comment('商品所属分类'); |
|||
$table->integer('store_id')->comment('所属商家'); |
|||
$table->string('cover_img')->default('')->comment('封面图'); |
|||
$table->decimal('price')->comment('售价'); |
|||
$table->decimal('original_price')->comment('原价'); |
|||
$table->decimal('vip_price')->comment('会员价'); |
|||
$table->integer('on_sale')->default('1')->comment('是否上架'); |
|||
$table->integer('inventory')->comment('库存'); |
|||
$table->string('content')->default('')->comment('简介'); |
|||
$table->integer('sort')->comment('排序'); |
|||
$table->integer('restrict_num')->comment('限购份数'); |
|||
$table->integer('start_num')->comment('起售份数'); |
|||
$table->integer('is_infinite')->default('1')->comment('是否开启无限库存'); |
|||
$table->string('good_unit')->nullable()->comment('商品单位'); |
|||
$table->json('tags')->nullable()->comment('标签'); |
|||
$table->json('details_imgs')->nullable()->comment('详情图片'); |
|||
$table->json('spec')->nullable()->comment('规格'); |
|||
$table->timestamps(); |
|||
$table->softDeletes(); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Reverse the migrations. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function down() |
|||
{ |
|||
Schema::dropIfExists('lanzu_goods'); |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
<?php |
|||
return [ |
|||
'labels' => [ |
|||
'Goods' => 'Goods', |
|||
], |
|||
'fields' => [ |
|||
'name' => '商品名称', |
|||
'type_id' => '商品所属分类', |
|||
'store_id' => '所属商家', |
|||
'cover_img' => '封面图', |
|||
'price' => '售价', |
|||
'original_price' => '原价', |
|||
'vip_price' => '会员价', |
|||
'on_sale' => '是否上架', |
|||
'inventory' => '库存', |
|||
'content' => '简介', |
|||
'sort' => '排序', |
|||
'restrict_num' => '限购份数', |
|||
'start_num' => '起售份数', |
|||
'is_infinite' => '是否开启无限库存', |
|||
'good_unit' => '商品单位', |
|||
'tags' => '标签', |
|||
'details_imgs' => '详情图片', |
|||
'spec' => '规格', |
|||
], |
|||
'options' => [ |
|||
], |
|||
]; |
|||
@ -0,0 +1,41 @@ |
|||
<?php |
|||
return [ |
|||
'labels' => [ |
|||
'Store' => '店铺管理', |
|||
'store' => '店铺管理', |
|||
], |
|||
'fields' => [ |
|||
'market_id' => '所属市场', |
|||
'market_name' => '所属市场', |
|||
'name' => '商家名称', |
|||
'address' => '商家地址', |
|||
'time' => '营业时间', |
|||
'time2' => '营业时间', |
|||
'time3' => '营业时间', |
|||
'time4' => '营业时间', |
|||
'tel' => '电话(座机)', |
|||
'announcement' => '公告', |
|||
'is_rest' => '是否休息', |
|||
'logo' => 'logo', |
|||
'logo_url' => 'logo', |
|||
'introduction' => '商家简介', |
|||
'coordinates' => '经纬度', |
|||
'business_license' => '营业资质', |
|||
'store_type_id' => '店铺所属分类', |
|||
'store_type_name' => '店铺分类', |
|||
'is_open' => '是否开启门店', |
|||
'sort' => '排序', |
|||
'user_id' => '提现用户', |
|||
'environment' => '商家环境', |
|||
'expire_time' => '到期时间', |
|||
'zm_img' => '身份证正面', |
|||
'fm_img' => '身份证反面', |
|||
'link_name' => '联系人姓名', |
|||
'link_tel' => '电话号码(手机)', |
|||
'admin_id' => '管理员', |
|||
'loudspeaker_imei' => '喇叭终端的机器码IMEI码', |
|||
'mm_user_id' => '所属市场经理', |
|||
], |
|||
'options' => [ |
|||
], |
|||
]; |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue