|
@@ -2,7 +2,6 @@
|
|
|
|
|
|
use App\Http\Requests\Admin\Product as Request;
|
|
|
use App\Models\AdminHistory;
|
|
|
-use App\Models\AdminUser;
|
|
|
use App\Models\Business;
|
|
|
use App\Models\City;
|
|
|
use App\Models\OrdersProduct;
|
|
@@ -16,6 +15,7 @@ use App\Models\Product\Skus as ProductSkus;
|
|
|
use App\Models\Product\City as ProductCity;
|
|
|
use App\Models\ProductPhoto;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
+use App\Models\WeiBan\Tags as WeiBanTags;
|
|
|
|
|
|
/**
|
|
|
* 产品管理
|
|
@@ -111,7 +111,7 @@ class Product extends Auth{
|
|
|
* 添加
|
|
|
*
|
|
|
* */
|
|
|
- public function add( Request $request, Model $Model,ProductPhoto $ProductPhoto,Producer $Producer,Business $Business,ProductType $ProductType,ProductSpec $ProductSpec,ProductAttr $ProductAttr,ProductSkus $ProductSkus,City $City,ProductCity $ProductCity){
|
|
|
+ public function add( Request $request, Model $Model,WeiBanTags $WeiBanTags,ProductPhoto $ProductPhoto,Producer $Producer,Business $Business,ProductType $ProductType,ProductSpec $ProductSpec,ProductAttr $ProductAttr,ProductSkus $ProductSkus,City $City,ProductCity $ProductCity){
|
|
|
if( request()->isMethod('post') ){
|
|
|
// 验证参数
|
|
|
$request->scene('add')->validate();
|
|
@@ -137,6 +137,10 @@ class Product extends Auth{
|
|
|
$skuList = request('sku',[]);
|
|
|
$cityIds = request('city_ids',[]);
|
|
|
$photoList = request('photo_list',[]);
|
|
|
+ $tagScope = request('tag_scope',[]);
|
|
|
+ $data['tag_scope'] = implode(',',$tagScope);
|
|
|
+ $tagExclude = request('tag_exclude',[]);
|
|
|
+ $data['tag_exclude'] = implode(',',$tagExclude);
|
|
|
// 循环
|
|
|
foreach ($photoList as $key => $value) {
|
|
|
if( !$value ) unset($photoList[$key]);
|
|
@@ -286,8 +290,17 @@ class Product extends Auth{
|
|
|
$cityList = $City->getCityList();
|
|
|
$businessList = $Business->getList();
|
|
|
$producerList = $Producer->getList();
|
|
|
+ // 标签列表
|
|
|
+ $tagData = $WeiBanTags->query()->groupBy('group')->groupBy('name')->get(['group','name'])->toArray();
|
|
|
+ // 标签列表
|
|
|
+ $tagList = [];
|
|
|
+ // 循环数据
|
|
|
+ foreach ($tagData as $value) {
|
|
|
+ $tagList[$value['group']][] = $value['name'];
|
|
|
+ }
|
|
|
// 分配数据
|
|
|
$this->assign('crumbs','新增');
|
|
|
+ $this->assign('tagList',$tagList);
|
|
|
$this->assign('typeList',$typeList);
|
|
|
$this->assign('cityList',$cityList);
|
|
|
$this->assign('businessList',$businessList);
|
|
@@ -300,7 +313,7 @@ class Product extends Auth{
|
|
|
* 编辑
|
|
|
*
|
|
|
* */
|
|
|
- public function edit( Request $request, Model $Model,ProductPhoto $ProductPhoto,Producer $Producer,Business $Business,ProductType $ProductType,ProductSpec $ProductSpec,ProductAttr $ProductAttr,ProductSkus $ProductSkus,City $City,ProductCity $ProductCity){
|
|
|
+ public function edit( Request $request, Model $Model,WeiBanTags $WeiBanTags,ProductPhoto $ProductPhoto,Producer $Producer,Business $Business,ProductType $ProductType,ProductSpec $ProductSpec,ProductAttr $ProductAttr,ProductSkus $ProductSkus,City $City,ProductCity $ProductCity){
|
|
|
if(request()->isMethod('post')){
|
|
|
// 验证参数
|
|
|
$request->scene('edit')->validate();
|
|
@@ -326,6 +339,10 @@ class Product extends Auth{
|
|
|
$skuList = request('sku',[]);
|
|
|
$cityIds = request('city_ids',[]);
|
|
|
$photoList = request('photo_list',[]);
|
|
|
+ $tagScope = request('tag_scope',[]);
|
|
|
+ $data['tag_scope'] = implode(',',$tagScope);
|
|
|
+ $tagExclude = request('tag_exclude',[]);
|
|
|
+ $data['tag_exclude'] = implode(',',$tagExclude);
|
|
|
// 循环
|
|
|
foreach ($photoList as $key => $value) {
|
|
|
if( !$value ) unset($photoList[$key]);
|
|
@@ -469,6 +486,8 @@ class Product extends Auth{
|
|
|
$oldData = $oldData->toArray();
|
|
|
$oldData['description'] = $Model->getDesc($id);
|
|
|
$oldData['city_ids'] = $ProductCity->getListByProductId($id);
|
|
|
+ $oldData['tag_scope'] = explode(',',$oldData['tag_scope']);
|
|
|
+ $oldData['tag_exclude'] = explode(',',$oldData['tag_exclude']);
|
|
|
$photoList = $ProductPhoto->getListByProductId($id);
|
|
|
// 获取产品属性
|
|
|
$attrList = $ProductAttr->getListByProductId($id);
|
|
@@ -501,7 +520,16 @@ class Product extends Auth{
|
|
|
$cityList = $City->getCityList();
|
|
|
$businessList = $Business->getList();
|
|
|
$producerList = $Producer->getList();
|
|
|
+ // 标签列表
|
|
|
+ $tagData = $WeiBanTags->query()->groupBy('group')->groupBy('name')->get(['group','name'])->toArray();
|
|
|
+ // 标签列表
|
|
|
+ $tagList = [];
|
|
|
+ // 循环数据
|
|
|
+ foreach ($tagData as $value) {
|
|
|
+ $tagList[$value['group']][] = $value['name'];
|
|
|
+ }
|
|
|
// 分配数据
|
|
|
+ $this->assign('tagList',$tagList);
|
|
|
$this->assign('typeList',$typeList);
|
|
|
$this->assign('cityList',$cityList);
|
|
|
$this->assign('businessList',$businessList);
|
|
@@ -520,7 +548,7 @@ class Product extends Auth{
|
|
|
* 编辑
|
|
|
*
|
|
|
* */
|
|
|
- public function copy( Request $request, Model $Model,ProductPhoto $ProductPhoto,Producer $Producer,Business $Business,ProductType $ProductType,ProductSpec $ProductSpec,ProductAttr $ProductAttr,ProductSkus $ProductSkus,City $City,ProductCity $ProductCity){
|
|
|
+ public function copy( Request $request, Model $Model,WeiBanTags $WeiBanTags,ProductPhoto $ProductPhoto,Producer $Producer,Business $Business,ProductType $ProductType,ProductSpec $ProductSpec,ProductAttr $ProductAttr,ProductSkus $ProductSkus,City $City,ProductCity $ProductCity){
|
|
|
if( request()->isMethod('post') ){
|
|
|
// 验证参数
|
|
|
$request->scene('add')->validate();
|
|
@@ -544,6 +572,10 @@ class Product extends Auth{
|
|
|
$skuList = request('sku',[]);
|
|
|
$cityIds = request('city_ids',[]);
|
|
|
$photoList = request('photo_list',[]);
|
|
|
+ $tagScope = request('tag_scope',[]);
|
|
|
+ $data['tag_scope'] = implode(',',$tagScope);
|
|
|
+ $tagExclude = request('tag_exclude',[]);
|
|
|
+ $data['tag_exclude'] = implode(',',$tagExclude);
|
|
|
// 循环
|
|
|
foreach ($photoList as $key => $value) {
|
|
|
if( !$value ) unset($photoList[$key]);
|
|
@@ -689,6 +721,8 @@ class Product extends Auth{
|
|
|
$oldData = $oldData->toArray();
|
|
|
$oldData['description'] = $Model->getDesc($id);
|
|
|
$oldData['city_ids'] = $ProductCity->getListByProductId($id);
|
|
|
+ $oldData['tag_scope'] = explode(',',$oldData['tag_scope']);
|
|
|
+ $oldData['tag_exclude'] = explode(',',$oldData['tag_exclude']);
|
|
|
$photoList = $ProductPhoto->getListByProductId($id);
|
|
|
// 获取产品属性
|
|
|
$attrList = $ProductAttr->getListByProductId($id);
|
|
@@ -716,12 +750,21 @@ class Product extends Auth{
|
|
|
// 重组
|
|
|
$skuList[$key] = $value;
|
|
|
}
|
|
|
+ // 标签列表
|
|
|
+ $tagData = $WeiBanTags->query()->groupBy('group')->groupBy('name')->get(['group','name'])->toArray();
|
|
|
+ // 标签列表
|
|
|
+ $tagList = [];
|
|
|
+ // 循环数据
|
|
|
+ foreach ($tagData as $value) {
|
|
|
+ $tagList[$value['group']][] = $value['name'];
|
|
|
+ }
|
|
|
// 获取类型数据
|
|
|
$typeList = $ProductType->getList();
|
|
|
$cityList = $City->getCityList();
|
|
|
$businessList = $Business->getList();
|
|
|
$producerList = $Producer->getList();
|
|
|
// 分配数据
|
|
|
+ $this->assign('tagList',$tagList);
|
|
|
$this->assign('typeList',$typeList);
|
|
|
$this->assign('cityList',$cityList);
|
|
|
$this->assign('businessList',$businessList);
|