diff --git a/app/Admin/Controllers/GoodsController.php b/app/Admin/Controllers/GoodsController.php new file mode 100644 index 0000000..3455e95 --- /dev/null +++ b/app/Admin/Controllers/GoodsController.php @@ -0,0 +1,106 @@ +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'); + }); + } +} diff --git a/app/Admin/Controllers/StoreController.php b/app/Admin/Controllers/StoreController.php new file mode 100644 index 0000000..e9c3f42 --- /dev/null +++ b/app/Admin/Controllers/StoreController.php @@ -0,0 +1,162 @@ +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("通过网址 https://lbs.amap.com/console/show/picker 获取经纬度"); + $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()){ + // 生产二维码 + + } + + }); + }); + } +} diff --git a/app/Admin/Repositories/Goods.php b/app/Admin/Repositories/Goods.php new file mode 100644 index 0000000..eb756da --- /dev/null +++ b/app/Admin/Repositories/Goods.php @@ -0,0 +1,16 @@ +resource('/storeUserReport', 'StoreUserReportController'); - //分类 + // 分类 $router->resource('/storeType', 'StoreTypeController'); $router->resource('/goodsType', 'GoodsTypeController'); $router->resource('/typeCorrelation', 'TypeCorrelationController'); + // 店铺 + $router->resource('/store', 'StoreController'); + // 商品 + $router->resource('/goods', 'GoodsController'); }); diff --git a/app/Models/Goods.php b/app/Models/Goods.php new file mode 100644 index 0000000..d43de89 --- /dev/null +++ b/app/Models/Goods.php @@ -0,0 +1,21 @@ +where('status',1) + ->whereNull('deleted_at') + ->get(); + $item = []; foreach ($markets as $market) { $item[$market->id] = $market->name; } return $item; } + /** + * 获取单个市场信息 + */ + public static function getMarketInfo($id,$field = '*') + { + return self::select($field)->find($id); + } + } diff --git a/app/Models/LanzuMmInfo.php b/app/Models/LanzuMmInfo.php index 748f29d..cb684ea 100644 --- a/app/Models/LanzuMmInfo.php +++ b/app/Models/LanzuMmInfo.php @@ -16,4 +16,23 @@ class LanzuMmInfo extends Model { return $this->hasOne('\App\Models\LanzuMmWithdraw','mm_id','id'); } + + /** + * 获取市场经理(只搜索状态是正常的经理) + * id为键,name为值 + */ + public static function getMmInfoArray() + { + $list = self::select('id','name') + ->where('is_del',0) + ->where('status',1) + ->get(); + $array = []; + if(count($list) > 0){ + foreach ($list as $key => $value){ + $array[$value->id] = $value->name; + } + } + return $array; + } } diff --git a/app/Models/Store.php b/app/Models/Store.php new file mode 100644 index 0000000..50bd72f --- /dev/null +++ b/app/Models/Store.php @@ -0,0 +1,92 @@ +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; + } + } +} diff --git a/app/Models/StoreType.php b/app/Models/StoreType.php index 1dfc154..9efbb3c 100644 --- a/app/Models/StoreType.php +++ b/app/Models/StoreType.php @@ -5,6 +5,7 @@ namespace App\Models; use Dcat\Admin\Traits\HasDateTimeFormatter; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\Model; +use phpDocumentor\Reflection\Project; class StoreType extends Model { @@ -39,6 +40,38 @@ class StoreType extends Model return $this->imageUrl($value); } + /** + * 获取单个一级分类信息 + * @param int $id + * @param string $field + * @return object + */ + public static function getStoreTypeInfo($id,$field = '*') + { + return self::select($field)->find($id); + } + + /** + * 获取一级分类数组 + * id为键,name为值 + * @return array + */ + public static function getStoreTypeArray() + { + $list = self::select('id','type_name') + ->where('status',1) + ->whereNull('deleted_at') + ->get(); + $array = []; + if(count($list) > 0){ + foreach ($list as $value) { + $array[$value->id] = $value->type_name; + } + } + + return $array; + } + // 处理图片 public function imageUrl($value) { diff --git a/app/Models/TypeCorrelation.php b/app/Models/TypeCorrelation.php index f114117..68e35a5 100644 --- a/app/Models/TypeCorrelation.php +++ b/app/Models/TypeCorrelation.php @@ -3,7 +3,7 @@ namespace App\Models; use Dcat\Admin\Traits\HasDateTimeFormatter; -use App\Models\LanzuStore; +use App\Models\Store as StoreModel; use Illuminate\Database\Eloquent\Model; class TypeCorrelation extends Model @@ -18,13 +18,8 @@ class TypeCorrelation extends Model public function getStoreTypeNameAttribute() { - $store = $this->getStoreInfo($this->store_type_id,'name'); - + $store = StoreModel::getStoreInfo($this->store_type_id,'name'); return $store ? $store->name : ''; } - public function getStoreInfo($id,$field = '*') - { - return LanzuStore::select($field)->find($id); - } } diff --git a/database/migrations/2020_09_01_094230_create_lanzu_store_table.php b/database/migrations/2020_09_01_094230_create_lanzu_store_table.php new file mode 100644 index 0000000..c71074b --- /dev/null +++ b/database/migrations/2020_09_01_094230_create_lanzu_store_table.php @@ -0,0 +1,59 @@ +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'); + } +} diff --git a/database/migrations/2020_09_01_095556_create_lanzu_goods_table.php b/database/migrations/2020_09_01_095556_create_lanzu_goods_table.php new file mode 100644 index 0000000..eb341ba --- /dev/null +++ b/database/migrations/2020_09_01_095556_create_lanzu_goods_table.php @@ -0,0 +1,50 @@ +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'); + } +} diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index e8bdfbe..6f73a14 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -86,6 +86,9 @@ namespace Dcat\Admin { * @property Grid\Column|Collection cover_img_url * @property Grid\Column|Collection created_at_text * @property Grid\Column|Collection updated_at_text + * @property Grid\Column|Collection store_type_name + * @property Grid\Column|Collection goods_type_id + * @property Grid\Column|Collection store_type_id * @property Grid\Column|Collection parent_id * @property Grid\Column|Collection order * @property Grid\Column|Collection icon @@ -1166,6 +1169,7 @@ namespace Dcat\Admin { * @property Grid\Column|Collection original_price * @property Grid\Column|Collection vip_price * @property Grid\Column|Collection on_sale + * @property Grid\Column|Collection is_infinite * @property Grid\Column|Collection tags * @property Grid\Column|Collection details_imgs * @property Grid\Column|Collection is_del @@ -1188,13 +1192,11 @@ namespace Dcat\Admin { * @property Grid\Column|Collection device_name * @property Grid\Column|Collection bind_time * @property Grid\Column|Collection business_license - * @property Grid\Column|Collection store_type_id * @property Grid\Column|Collection expire_time * @property Grid\Column|Collection pay_status * @property Grid\Column|Collection apply_time * @property Grid\Column|Collection store_applet_img * @property Grid\Column|Collection cash_code_img - * @property Grid\Column|Collection goods_type_id * @property Grid\Column|Collection nick_name * @property Grid\Column|Collection real_name * @property Grid\Column|Collection balance @@ -1276,6 +1278,9 @@ namespace Dcat\Admin { * @method Grid\Column|Collection cover_img_url(string $label = null) * @method Grid\Column|Collection created_at_text(string $label = null) * @method Grid\Column|Collection updated_at_text(string $label = null) + * @method Grid\Column|Collection store_type_name(string $label = null) + * @method Grid\Column|Collection goods_type_id(string $label = null) + * @method Grid\Column|Collection store_type_id(string $label = null) * @method Grid\Column|Collection parent_id(string $label = null) * @method Grid\Column|Collection order(string $label = null) * @method Grid\Column|Collection icon(string $label = null) @@ -2356,6 +2361,7 @@ namespace Dcat\Admin { * @method Grid\Column|Collection original_price(string $label = null) * @method Grid\Column|Collection vip_price(string $label = null) * @method Grid\Column|Collection on_sale(string $label = null) + * @method Grid\Column|Collection is_infinite(string $label = null) * @method Grid\Column|Collection tags(string $label = null) * @method Grid\Column|Collection details_imgs(string $label = null) * @method Grid\Column|Collection is_del(string $label = null) @@ -2378,13 +2384,11 @@ namespace Dcat\Admin { * @method Grid\Column|Collection device_name(string $label = null) * @method Grid\Column|Collection bind_time(string $label = null) * @method Grid\Column|Collection business_license(string $label = null) - * @method Grid\Column|Collection store_type_id(string $label = null) * @method Grid\Column|Collection expire_time(string $label = null) * @method Grid\Column|Collection pay_status(string $label = null) * @method Grid\Column|Collection apply_time(string $label = null) * @method Grid\Column|Collection store_applet_img(string $label = null) * @method Grid\Column|Collection cash_code_img(string $label = null) - * @method Grid\Column|Collection goods_type_id(string $label = null) * @method Grid\Column|Collection nick_name(string $label = null) * @method Grid\Column|Collection real_name(string $label = null) * @method Grid\Column|Collection balance(string $label = null) @@ -2471,6 +2475,9 @@ namespace Dcat\Admin { * @property Show\Field|Collection cover_img_url * @property Show\Field|Collection created_at_text * @property Show\Field|Collection updated_at_text + * @property Show\Field|Collection store_type_name + * @property Show\Field|Collection goods_type_id + * @property Show\Field|Collection store_type_id * @property Show\Field|Collection parent_id * @property Show\Field|Collection order * @property Show\Field|Collection icon @@ -3551,6 +3558,7 @@ namespace Dcat\Admin { * @property Show\Field|Collection original_price * @property Show\Field|Collection vip_price * @property Show\Field|Collection on_sale + * @property Show\Field|Collection is_infinite * @property Show\Field|Collection tags * @property Show\Field|Collection details_imgs * @property Show\Field|Collection is_del @@ -3573,13 +3581,11 @@ namespace Dcat\Admin { * @property Show\Field|Collection device_name * @property Show\Field|Collection bind_time * @property Show\Field|Collection business_license - * @property Show\Field|Collection store_type_id * @property Show\Field|Collection expire_time * @property Show\Field|Collection pay_status * @property Show\Field|Collection apply_time * @property Show\Field|Collection store_applet_img * @property Show\Field|Collection cash_code_img - * @property Show\Field|Collection goods_type_id * @property Show\Field|Collection nick_name * @property Show\Field|Collection real_name * @property Show\Field|Collection balance @@ -3661,6 +3667,9 @@ namespace Dcat\Admin { * @method Show\Field|Collection cover_img_url(string $label = null) * @method Show\Field|Collection created_at_text(string $label = null) * @method Show\Field|Collection updated_at_text(string $label = null) + * @method Show\Field|Collection store_type_name(string $label = null) + * @method Show\Field|Collection goods_type_id(string $label = null) + * @method Show\Field|Collection store_type_id(string $label = null) * @method Show\Field|Collection parent_id(string $label = null) * @method Show\Field|Collection order(string $label = null) * @method Show\Field|Collection icon(string $label = null) @@ -4741,6 +4750,7 @@ namespace Dcat\Admin { * @method Show\Field|Collection original_price(string $label = null) * @method Show\Field|Collection vip_price(string $label = null) * @method Show\Field|Collection on_sale(string $label = null) + * @method Show\Field|Collection is_infinite(string $label = null) * @method Show\Field|Collection tags(string $label = null) * @method Show\Field|Collection details_imgs(string $label = null) * @method Show\Field|Collection is_del(string $label = null) @@ -4763,13 +4773,11 @@ namespace Dcat\Admin { * @method Show\Field|Collection device_name(string $label = null) * @method Show\Field|Collection bind_time(string $label = null) * @method Show\Field|Collection business_license(string $label = null) - * @method Show\Field|Collection store_type_id(string $label = null) * @method Show\Field|Collection expire_time(string $label = null) * @method Show\Field|Collection pay_status(string $label = null) * @method Show\Field|Collection apply_time(string $label = null) * @method Show\Field|Collection store_applet_img(string $label = null) * @method Show\Field|Collection cash_code_img(string $label = null) - * @method Show\Field|Collection goods_type_id(string $label = null) * @method Show\Field|Collection nick_name(string $label = null) * @method Show\Field|Collection real_name(string $label = null) * @method Show\Field|Collection balance(string $label = null) diff --git a/resources/lang/zh-CN/goods.php b/resources/lang/zh-CN/goods.php new file mode 100644 index 0000000..360bd33 --- /dev/null +++ b/resources/lang/zh-CN/goods.php @@ -0,0 +1,28 @@ + [ + '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' => [ + ], +]; diff --git a/resources/lang/zh-CN/store.php b/resources/lang/zh-CN/store.php new file mode 100644 index 0000000..97f7d13 --- /dev/null +++ b/resources/lang/zh-CN/store.php @@ -0,0 +1,41 @@ + [ + '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' => [ + ], +];