dyjh 6 роки тому
батько
коміт
ad1645e4e1

+ 5 - 1
app/Http/Controllers/Admin/Album/Product/PriceController.php

xqd xqd
@@ -29,7 +29,8 @@ class PriceController extends Controller
         $agent_id = $request->input('id');
         //dd($agent_id);die;
         $search['keyword'] = $request->input('keyword');
-        $query = $this->repository->pushCriteria(new PriceWhere($search,$this->getStoreId(),$agent_id));
+        $search['cat_id'] = $request->input('cat_id');
+        $query = $this->repository->pushCriteria(new PriceWhere($search, $this->getStoreId(), $agent_id));
 
         if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
         $query = $query->pushCriteria(new OrderBy($request['sort_field'],$request['sort_field_by']));
@@ -40,6 +41,9 @@ class PriceController extends Controller
         foreach ($list as $item){
             $product = AlbumProductModel::where([['id',$item->product_id],['store_id',$this->getStoreId()]])->first();
             $item->product_name = $product['name'];
+            $cat = AlbumCatModel::where('id', $product['cat_id'])->first();
+            $item->product_cat = $cat->name;
+            $item->product_ma_price_comment = $product['ma_price_comment'];
             $item->product_pic = $product['cover_pic'];
         }
         $cat = AlbumCatModel::where([['store_id',$this->getStoreId()],['parent_id',0]])->get();

+ 5 - 0
app/Http/Controllers/Api/V1/AlbumController.php

xqd xqd xqd
@@ -1550,6 +1550,7 @@ class AlbumController extends Controller
         $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
         $agent_id = $user_agent['id'];
         $data = $request->all();
+        $product = AlbumProductModel::where('id', $data['goods_id'])->first();
         //print_r($data);
         $save = array();
         $return_data = array();
@@ -1559,6 +1560,8 @@ class AlbumController extends Controller
         if(empty($check)){
             $save['agent_id'] = $agent_id;
             $save['store_id'] = $data['store_id'];
+            $save['cat_id'] = $product->cat_id;
+            $save['name'] = $product->name;
             $save['product_id'] = $data['goods_id'];
             $res = AlbumProductPriceModel::create($save);
         }else{
@@ -2756,6 +2759,8 @@ class AlbumController extends Controller
             if(empty($check)){
                 $save['agent_id'] = $user_agent->id;
                 $save['store_id'] = $data['store_id'];
+                $save['cat_id'] = $val['cat_id'];
+                $save['name'] = $val['name'];
                 $save['product_id'] = $val['id'];
                 AlbumProductPriceModel::create($save);
             }else{

+ 2 - 0
app/Models/AlbumProductPriceModel.php

xqd
@@ -32,6 +32,8 @@ class AlbumProductPriceModel extends BaseModel
      */
     protected $fillable = [
                            'agent_id',
+                           'name',
+                           'cat_id',
                            'store_id',
                            'product_id',
                            'mobile',

+ 4 - 1
app/Repositories/Album/Criteria/PriceWhere.php

xqd xqd
@@ -11,6 +11,7 @@ namespace App\Repositories\Album\Criteria;
 
 
 
+use App\Models\AlbumProductModel;
 use App\Repositories\Base\Criteria;
 use App\Repositories\Contracts\RepositoryInterface as Repository;
 
@@ -48,7 +49,9 @@ class PriceWhere extends Criteria {
         } else {
             $model = $model->where([['store_id',$this->store_id],['agent_id',$this->agent_id]]);
         }
-
+        if (isset($this->search['cat_id']) && $this->search['cat_id'] > 0) {
+            $model = $model->where([['cat_id',$this->search['cat_id']]]);
+        }
         return $model;
     }
 

+ 34 - 0
database/migrations/2019_04_16_183629_add_column_cat_id_to_album_product_price.php

xqd
@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddColumnCatIdToAlbumProductPrice extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('album_product_price', function (Blueprint $table) {
+            //
+            $table->unsignedInteger('cat_id')->default(0);
+            $table->string('name', 255)->nullable()->default(null);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('album_product_price', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 6 - 2
resources/views/admin/album/product/price/index.blade.php

xqd xqd
@@ -51,10 +51,12 @@
     						<tr>
 								
             <th class="sorting" data-sort="id"> ID </th>
-            <th class="sorting" data-sort="product_name"> 商品名 </th>
-            <th class="sorting" data-sort="product_pic"> 商品图片 </th>
+            <th> 商品名 </th>
+            <th> 商品分类 </th>
+            <th> 商品图片 </th>
             <th class="sorting" data-sort="product_id"> 商品ID </th>
             <th class="sorting" data-sort="mobile"> 经销商电话 </th>
+            <th> 厂家价 </th>
             <th class="sorting" data-sort="price"> 价格 </th>
         						{{--<th width="22%">相关操作</th>--}}
         					</tr>
@@ -65,9 +67,11 @@
 								
             <td>{{ $item->id }}</td>
             <td>{{ $item->product_name }}</td>
+            <td>{{ $item->cat }}</td>
             <td><img src="{{ $item->product_pic }}" width="50"/></td>
             <td>{{ $item->product_id }}</td>
             <td>{{ $item->mobile }}</td>
+            <td>{{ $item->product_ma_price_comment }}</td>
             <td>{{ $item->price }}</td>
 								{{--<td>
 									<div class="btn-group">