diff --git a/beike/Admin/Http/Controllers/ProductController.php b/beike/Admin/Http/Controllers/ProductController.php index 444a2e23..e73739f0 100644 --- a/beike/Admin/Http/Controllers/ProductController.php +++ b/beike/Admin/Http/Controllers/ProductController.php @@ -117,6 +117,7 @@ class ProductController extends Controller 'descriptions' => $descriptions ?? [], 'category_ids' => $categoryIds ?? [], 'product_attributes' => ProductAttributeResource::collection($product->attributes), + 'relations' => ProductResource::collection($product->relations)->resource, 'languages' => LanguageRepo::all(), 'tax_classes' => TaxClassRepo::getList(), 'source' => [ diff --git a/beike/Admin/Services/ProductService.php b/beike/Admin/Services/ProductService.php index d065754e..acb9c5c0 100644 --- a/beike/Admin/Services/ProductService.php +++ b/beike/Admin/Services/ProductService.php @@ -59,6 +59,7 @@ class ProductService $product->skus()->createMany($skus); $product->categories()->sync($data['categories'] ?? []); + $product->relations()->sync($data['relations'] ?? []); DB::commit(); diff --git a/beike/Models/Product.php b/beike/Models/Product.php index e718ffa4..b1123e91 100644 --- a/beike/Models/Product.php +++ b/beike/Models/Product.php @@ -60,6 +60,11 @@ class Product extends Base return $this->belongsTo(Brand::Class, 'brand_id', 'id'); } + public function relations() + { + return $this->belongsToMany(Product::class, ProductRelation::class, 'product_id', 'relation_id')->withTimestamps(); + } + public function inCurrentWishlist() { $customer = current_customer(); diff --git a/beike/Models/ProductRelation.php b/beike/Models/ProductRelation.php new file mode 100644 index 00000000..c81fa31f --- /dev/null +++ b/beike/Models/ProductRelation.php @@ -0,0 +1,24 @@ + + * @created 2022-12-30 11:04:40 + * @modified 2022-12-30 11:04:40 + */ + +namespace Beike\Models; + +class ProductRelation extends Base +{ + protected $table = 'product_relations'; + protected $fillable = ['product_id', 'relation_id']; + + public function product() + { + return $this->hasMany(Product::class); + } + +} diff --git a/beike/Repositories/ProductRepo.php b/beike/Repositories/ProductRepo.php index 5fad9992..6f17a836 100644 --- a/beike/Repositories/ProductRepo.php +++ b/beike/Repositories/ProductRepo.php @@ -34,7 +34,7 @@ class ProductRepo if (is_int($product)) { $product = Product::query()->findOrFail($product); } - $product->load('description', 'skus', 'master_sku', 'brand'); + $product->load('description', 'skus', 'master_sku', 'brand', 'relations'); return $product; } diff --git a/beike/Shop/Http/Controllers/ProductController.php b/beike/Shop/Http/Controllers/ProductController.php index 0577a9f1..1b255303 100644 --- a/beike/Shop/Http/Controllers/ProductController.php +++ b/beike/Shop/Http/Controllers/ProductController.php @@ -18,9 +18,11 @@ class ProductController extends Controller */ public function show(Request $request, Product $product) { + $relationIds = $product->relations->pluck('id')->toArray(); $product = ProductRepo::getProductDetail($product); $data = [ 'product' => (new ProductDetail($product))->jsonSerialize(), + 'relations' => ProductRepo::getProductsByIds($relationIds)->jsonSerialize(), ]; $data = hook_filter('product.show', $data); return view('product', $data); diff --git a/database/migrations/2022_12_30_110019_create_product_related.php b/database/migrations/2022_12_30_110019_create_product_related.php new file mode 100644 index 00000000..7c26731f --- /dev/null +++ b/database/migrations/2022_12_30_110019_create_product_related.php @@ -0,0 +1,33 @@ +id(); + $table->unsignedInteger('product_id')->comment('商品 ID')->index('product_id'); + $table->unsignedInteger('relation_id')->comment('关联商品 ID')->index('relation_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('product_relations'); + } +}; diff --git a/plugins/Lianlianpay/Lang/en/common.php b/plugins/Lianlianpay/Lang/en/common.php new file mode 100644 index 00000000..3609fc40 --- /dev/null +++ b/plugins/Lianlianpay/Lang/en/common.php @@ -0,0 +1,29 @@ + + * @created 2022-12-27 16:19:06 + * @modified 2022-12-27 16:19:06 + */ + +return [ + 'merchant_id' => 'Merchant ID', + 'lianlianpay_public_key' => 'Lianlian Public-Key', + 'merchant_secret_key' => 'Merchant Secret Key', + 'test' => 'Test Mode', + + 'system_error' => 'system error', + 'customer_has_restrictions' => 'you has restrictions to perform exchange operation', + 'annual_limit_exceeded' => 'you has exceeded the annual limit. for you to continue shopping, send proof of income to request limit increase ', + 'boleto_limit_exceeded' => 'boleto_limit_exceeded ', + 'fx_transaction_limit_exceeded' => 'fx_transaction_limit_exceeded', + 'payment_completed' => 'payment_completed', + 'payment_closed' => 'payment_closed ', + 'refund_amount_exceeded' => 'the refund amount can not be greater than the amount of the order previously paid ', + 'non_refundable_order' => 'the current order status does not allow a refund', + 'refund_already_requested' => 'the refund of this order has already been requested.', + 'insufficient_balance' => 'merchant does not have enough balance for this operation ', +]; diff --git a/plugins/Lianlianpay/Lang/zh_cn/common.php b/plugins/Lianlianpay/Lang/zh_cn/common.php new file mode 100644 index 00000000..98bc3004 --- /dev/null +++ b/plugins/Lianlianpay/Lang/zh_cn/common.php @@ -0,0 +1,29 @@ + + * @created 2022-12-27 16:19:06 + * @modified 2022-12-27 16:19:06 + */ + +return [ + 'merchant_id' => '商户ID', + 'lianlianpay_public_key' => '连连公钥', + 'merchant_secret_key' => '商户私钥', + 'test' => '测试模式', + + 'system_error' => 'system error', + 'customer_has_restrictions' => 'you has restrictions to perform exchange operation', + 'annual_limit_exceeded' => 'you has exceeded the annual limit. for you to continue shopping, send proof of income to request limit increase ', + 'boleto_limit_exceeded' => 'boleto_limit_exceeded ', + 'fx_transaction_limit_exceeded' => 'fx_transaction_limit_exceeded', + 'payment_completed' => 'payment_completed', + 'payment_closed' => 'payment_closed ', + 'refund_amount_exceeded' => 'the refund amount can not be greater than the amount of the order previously paid ', + 'non_refundable_order' => 'the current order status does not allow a refund', + 'refund_already_requested' => 'the refund of this order has already been requested.', + 'insufficient_balance' => 'merchant does not have enough balance for this operation ', +];