调整砍价商品售后问题
parent
3a0ba59c3f
commit
7c278507eb
|
|
@ -41,6 +41,7 @@ class OrderProduct extends Model
|
|||
'remain_quantity',
|
||||
'is_gift',
|
||||
'activity_id',
|
||||
'bargain_amount',
|
||||
];
|
||||
|
||||
public function packageProducts()
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class OrderService
|
|||
$coupon = $user->coupons()->onlyAvailable()->lockForUpdate()->findOrFail($couponId);
|
||||
}
|
||||
|
||||
$mapProducts = $this->mapProducts($user, $products, $coupon);
|
||||
$mapProducts = $this->mapProducts($user, $products, $coupon, $bargainOrder);
|
||||
|
||||
// 计算运费
|
||||
$shippingFee = $this->calculateShippingFee($mapProducts, $shippingAddress);
|
||||
|
|
@ -675,13 +675,14 @@ class OrderService
|
|||
* @param \App\Models\User $user
|
||||
* @param array $products
|
||||
* @param \App\Models\UserCoupon|null $coupon
|
||||
* @param \App\Models\BargainOrder|null $bargainOrder
|
||||
* @return array
|
||||
*
|
||||
* @throws \App\Exceptions\BizException
|
||||
*/
|
||||
protected function mapProducts(User $user, array $products, ?UserCoupon $coupon): array
|
||||
protected function mapProducts(User $user, array $products, ?UserCoupon $coupon, ?BargainOrder $bargainOrder): array
|
||||
{
|
||||
$_products = collect($products)->map(function ($item) use ($user) {
|
||||
$_products = collect($products)->map(function ($item) use ($user, $bargainOrder) {
|
||||
$sku = $item['sku'];
|
||||
|
||||
return array_merge($item, [
|
||||
|
|
@ -695,6 +696,8 @@ class OrderService
|
|||
'total_amount' => $sku->sell_price * $item['quantity'],
|
||||
// 总销售值
|
||||
'total_sales_value' => bcmul($sku->sales_value, $item['quantity'], 2),
|
||||
//填入砍价金额
|
||||
'bargain_amount'=> $bargainOrder?->bargain_price ?? 0,
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddBargainAmountToOrderProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('order_products', function (Blueprint $table) {
|
||||
//
|
||||
$table->unsignedBigInteger('bargain_amount')->nullable()->default(0)->comment('砍价金额');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('order_products', function (Blueprint $table) {
|
||||
//
|
||||
$table->dropColumn(['bargain_amount']);
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue