6
0
Fork 0

取消订单时退优惠券

release
vine_liutk 2021-12-23 16:25:20 +08:00
parent 9d6acd9df8
commit cde7b6d836
2 changed files with 8 additions and 1 deletions

View File

@ -825,6 +825,13 @@ class OrderService
}
}
// 取消订单,退券
if ($order->user_coupon_id) {
UserCoupon::where('user_id', $order->user_id)->where('id', $order->user_coupon_id)->update([
'is_use'=>false,
]);
}
$order->update([
'status' => Order::STATUS_CANCELLED,
]);

View File

@ -14,7 +14,7 @@ class AddCouponIdToOrdersTable extends Migration
public function up()
{
Schema::table('orders', function (Blueprint $table) {
$table->unsignedBigInteger('user_coupon_id')->unique()->nullable()->comment('用户优惠券ID');
$table->unsignedBigInteger('user_coupon_id')->nullable()->comment('用户优惠券ID');
});
}