v1.1 修改完成
This commit is contained in:
parent
c86d9a8087
commit
b57dcf54b0
|
|
@ -25,8 +25,11 @@ class InquiryRepo
|
|||
public static function getList(): LengthAwarePaginator
|
||||
{
|
||||
$builder = Inquiry::query()->with([
|
||||
'productsku', 'productsku.product','productsku.product' => function ($query) {
|
||||
$query->with(['description']);
|
||||
'productsku' => function($query) {
|
||||
$query->withTrashed();
|
||||
},
|
||||
'productsku.product' => function($query) {
|
||||
$query->withTrashed()->with(['description']);
|
||||
},
|
||||
])->orderByDesc('updated_at');
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,9 @@ class ProductService
|
|||
}
|
||||
$product->skus()->createMany($skus);
|
||||
|
||||
$product->numPrices()->createMany(list_sort_by($data['numPrices'],'num') ?? []);
|
||||
if($data['price_setting'] == 'num' && !empty($data['numPrices'])){
|
||||
$product->numPrices()->createMany(list_sort_by($data['numPrices'],'num') ?? []);
|
||||
}
|
||||
|
||||
$product->categories()->sync($data['categories'] ?? []);
|
||||
$product->relations()->sync($data['relations'] ?? []);
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@
|
|||
namespace Beike\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ProductSku extends Base
|
||||
{
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = ['product_id', 'variants', 'position', 'images', 'model', 'sku', 'price', 'origin_price', 'cost_price', 'quantity', 'is_default'];
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,8 @@ class ProductRepo
|
|||
});
|
||||
$builder->leftJoin('product_skus', function ($build) {
|
||||
$build->whereColumn('product_skus.product_id', 'products.id')
|
||||
->where('is_default', 1);
|
||||
->where('is_default', 1)
|
||||
->where('product_skus.deleted_at', null);
|
||||
});
|
||||
$builder->select(['products.*', 'pd.name', 'pd.content', 'pd.meta_title', 'pd.meta_description', 'pd.meta_keywords', 'pd.name', 'product_skus.price']);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,36 +14,49 @@ namespace Beike\Shop\Http\Resources;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class InquiryDetail extends JsonResource
|
||||
{
|
||||
class InquiryDetail extends JsonResource{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function toArray($request): array
|
||||
{
|
||||
public function toArray($request):array{
|
||||
$productsku = $this->productsku;
|
||||
$product = $productsku->product;
|
||||
if($this->productsku == NULL){
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'product_sku_id' => $this->product_sku_id,
|
||||
'contacts' => $this->contacts,
|
||||
'email' => $this->email,
|
||||
'content' => $this->content,
|
||||
'product_sku_sku' => '',
|
||||
'product_name' => '',
|
||||
'product_images' => [],
|
||||
'product_id' => '',
|
||||
'created_at' => time_format($this->created_at),
|
||||
'updated_at' => time_format($this->updated_at),
|
||||
];
|
||||
}
|
||||
$product = $productsku->product;
|
||||
$description = $product->description;
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'product_sku_id' => $this->product_sku_id,
|
||||
'contacts' => $this->contacts,
|
||||
'email' => $this->email,
|
||||
'content' => $this->content,
|
||||
'product_sku_sku' => $productsku->sku,
|
||||
'product_name' => $description->name ?? '',
|
||||
'product_images' => array_map(function ($image) {
|
||||
'id' => $this->id,
|
||||
'product_sku_id' => $this->product_sku_id,
|
||||
'contacts' => $this->contacts,
|
||||
'email' => $this->email,
|
||||
'content' => $this->content,
|
||||
'product_sku_sku' => $productsku->sku,
|
||||
'product_name' => $description->name ?? '',
|
||||
'product_images' => array_map(function($image){
|
||||
return [
|
||||
'preview' => image_resize($image, 500, 500),
|
||||
'popup' => image_resize($image, 800, 800),
|
||||
'thumb' => image_resize($image, 150, 150),
|
||||
'preview' => image_resize($image,500,500),
|
||||
'popup' => image_resize($image,800,800),
|
||||
'thumb' => image_resize($image,150,150),
|
||||
];
|
||||
}, $product->images ?? []),
|
||||
'product_id' => $productsku->product_id,
|
||||
'created_at' => time_format($this->created_at),
|
||||
'updated_at' => time_format($this->updated_at),
|
||||
},$product->images ?? []),
|
||||
'product_id' => $productsku->product_id,
|
||||
'created_at' => time_format($this->created_at),
|
||||
'updated_at' => time_format($this->updated_at),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@
|
|||
<i class="el-icon-user"></i>
|
||||
{{ __('admin/product.products_name') }}-{{ __('common.sku') }}
|
||||
</template>
|
||||
<a class="text-dark" href="/products/@{{ dialog.form.product_id }}" target="_blank">@{{ dialog.form.product_name }}-@{{ dialog.form.product_sku_sku}}</a>
|
||||
<a class="text-dark" :href="'/products/' + dialog.form.product_id" target="_blank">@{{ dialog.form.product_name }}-@{{ dialog.form.product_sku_sku}}</a>
|
||||
</el-descriptions-item>
|
||||
|
||||
</el-descriptions>
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@
|
|||
<input type="hidden" name="variables" :value="JSON.stringify(form.variables)">
|
||||
|
||||
<span v-if="form.price_setting === 'sku'">
|
||||
<input type="hidden" name="numPrices" value="">
|
||||
<x-admin::form.row :title="__('admin/product.enable_multi_spec')">
|
||||
<el-switch v-model="editing.isVariable" @change="isVariableChange" class="mt-2"></el-switch>
|
||||
</x-admin::form.row>
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@
|
|||
</button>
|
||||
</div>
|
||||
@else
|
||||
<div class="text-danger"><i class="bi bi-exclamation-circle-fill"></i> {{ __('product.has_been_inactive') }}</div>
|
||||
{{-- <div class="text-danger"><i class="bi bi-exclamation-circle-fill"></i> {{ __('product.has_been_inactive') }}</div>--}}
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue