Browse Source

【Add】SKU增加市场价格

liuxiangxin 5 months ago
parent
commit
22347092da

+ 2 - 1
app/Http/Controllers/Admin/Product.php

@@ -921,12 +921,13 @@ class Product extends Auth{
 		// 循环规格属性
 		foreach ($skuList as $newKey => $new) {
 			// 获取新数据
-			$new		= ['attr_names'=>$new,'price'=>0,'stock'=>0,'min_quota'=>0,'quota'=>0,'status'=>0,'sku_thumb'=>''];
+			$new		= ['attr_names'=>$new,'price'=>0,'market_price'=>0,'stock'=>0,'min_quota'=>0,'quota'=>0,'status'=>0,'sku_thumb'=>''];
 			// 循环旧的sku
 			foreach ($oldSkus as $old) {
 				// 如果有相等的规格
 				if( $old['attr_names'] == $new['attr_names']) {
 					$new['sku_thumb']	= $old['sku_thumb'];
+					$new['market_price']= $old['market_price'];
 					$new['price']		= $old['price'];
 					$new['stock']		= $old['stock'];
 					$new['status']		= $old['status'];

+ 2 - 2
app/Models/Product/Skus.php

@@ -77,7 +77,7 @@ class Skus extends Model
     public function getListByIds($skuIds)
     {
         // 写入数据表
-        $data					= $this->query()->whereIn('id',$skuIds)->where([['status','=',0]])->get(['id as sku_id','product_id','attr_names as sku_attr_names','quota','min_quota','price','stock','status'])->toArray();
+        $data					= $this->query()->whereIn('id',$skuIds)->where([['status','=',0]])->get(['id as sku_id','product_id','attr_names as sku_attr_names','quota','min_quota','price','market_price','stock','status'])->toArray();
         // 列表
         $list                   = [];
         // 循环处理
@@ -97,7 +97,7 @@ class Skus extends Model
     public function getListByProductId($productId)
     {
         // 写入数据表
-        $list					= $this->query()->where([['product_id','=',$productId]])->get(['id','attr_ids','attr_names','min_quota','quota','sku_thumb','price','stock','status'])->toArray();
+        $list					= $this->query()->where([['product_id','=',$productId]])->get(['id','attr_ids','attr_names','min_quota','quota','sku_thumb','price','market_price','stock','status'])->toArray();
         // 返回结果
         return                  $list;
     }

+ 4 - 2
resources/views/admin/product/copy.blade.php

@@ -241,7 +241,8 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 							<th>{{$value['name']}}</th>
 							@endforeach
 							<th>配图</th>
-							<th>价格</th>
+							<th>原价</th>
+							<th>折扣价</th>
 							<th>库存</th>
 							<th>起购数量</th>
 							<th>限购数量</th>
@@ -263,7 +264,8 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 									<input type="hidden" name="sku[{{$value['attr_ids']}}][sku_thumb]" laceholder="缩略图" value="{{$value['sku_thumb']??''}}" id="input-sku_thumb{{$key}}" />
 								</div>
 							</td>
-							<td><input type="text" name="sku[{{$value['attr_ids']}}][price]" placeholder="价格" value="{{$value['price']}}"></td>
+							<td><input type="text" name="sku[{{$value['attr_ids']}}][market_price]" placeholder="原价" value="{{$value['market_price']}}"></td>
+							<td><input type="text" name="sku[{{$value['attr_ids']}}][price]" placeholder="折扣价" value="{{$value['price']}}"></td>
 							<td><input type="number" name="sku[{{$value['attr_ids']}}][stock]" placeholder="库存"  value="{{$value['stock']}}"></td>
 							<td><input type="number" name="sku[{{$value['attr_ids']}}][min_quota]" placeholder="起购数量" value="{{$value['min_quota']}}"></td>
 							<td><input type="number" name="sku[{{$value['attr_ids']}}][quota]" placeholder="限购数量" value="{{$value['quota']}}"></td>

+ 4 - 2
resources/views/admin/product/edit.blade.php

@@ -241,7 +241,8 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 							<th>{{$value['name']}}</th>
 							@endforeach
 							<th>配图</th>
-							<th>价格</th>
+							<th>原价</th>
+							<th>折扣价</th>
 							<th>库存</th>
 							<th>起购数量</th>
 							<th>限购数量</th>
@@ -263,7 +264,8 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 									<input type="hidden" name="sku[{{$value['attr_ids']}}][sku_thumb]" laceholder="缩略图" value="{{$value['sku_thumb']??''}}" id="input-sku_thumb{{$key}}" />
 								</div>
 							</td>
-							<td><input type="text" name="sku[{{$value['attr_ids']}}][price]" placeholder="价格" value="{{$value['price']}}"></td>
+							<td><input type="text" name="sku[{{$value['attr_ids']}}][market_price]" placeholder="原价" value="{{$value['market_price']}}"></td>
+							<td><input type="text" name="sku[{{$value['attr_ids']}}][price]" placeholder="折扣价" value="{{$value['price']}}"></td>
 							<td><input type="number" name="sku[{{$value['attr_ids']}}][stock]" placeholder="库存"  value="{{$value['stock']}}"></td>
 							<td><input type="number" name="sku[{{$value['attr_ids']}}][min_quota]" placeholder="起购数量" value="{{$value['min_quota']}}"></td>
 							<td><input type="number" name="sku[{{$value['attr_ids']}}][quota]" placeholder="限购数量" value="{{$value['quota']}}"></td>

+ 4 - 2
resources/views/admin/product/get_sku_html.blade.php

@@ -7,7 +7,8 @@
 					<th>{{$value['spec_name']}}</th>
 					@endforeach
 					<th>配图</th>
-					<th>价格</th>
+					<th>原价</th>
+					<th>折扣价</th>
 					<th>库存</th>
 					<th>起购数量</th>
 					<th>限购数量</th>
@@ -29,7 +30,8 @@
 							<input type="hidden" name="sku[{{$value['attr_names']}}][sku_thumb]" laceholder="缩略图" value="{{$value['sku_thumb']??''}}" id="input-sku_thumb{{$key}}" />
 						</div>
 					</td>
-					<td><input type="text" name="sku[{{$value['attr_names']}}][price]" placeholder="价格" value="{{$value['price']}}"></td>
+					<td><input type="text" name="sku[{{$value['attr_names']}}][market_price]" placeholder="原价" value="{{$value['market_price']}}"></td>
+					<td><input type="text" name="sku[{{$value['attr_names']}}][price]" placeholder="折扣价" value="{{$value['price']}}"></td>
 					<td><input type="number" name="sku[{{$value['attr_names']}}][stock]" placeholder="库存" value="{{$value['stock']}}"></td>
 					<td><input type="number" name="sku[{{$value['attr_names']}}][min_quota]" placeholder="起购数量" value="{{$value['min_quota']}}"></td>
 					<td><input type="number" name="sku[{{$value['attr_names']}}][quota]" placeholder="限购数量" value="{{$value['quota']}}"></td>