Compare commits

..

4 Commits
i ... main

Author SHA1 Message Date
pfr2jtqoi 3bb057a912 Add 444
8 months ago
pfr2jtqoi 7d11b142ed Add 122
8 months ago
pfr2jtqoi bbcb4ca236 j
8 months ago
pfr2jtqoi fb4369f1b1 Add hanyoujun
8 months ago

3234
122

File diff suppressed because it is too large Load Diff

3234
444

File diff suppressed because it is too large Load Diff

@ -16,57 +16,56 @@ class CancelUnPayOrder implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $order; // Property to hold the order instance
protected $order;
/**
* Create a new job instance.
*
* @param Order $order The order that needs to be processed
* @param Order $order
*/
public function __construct(Order $order)
{
$this->order = $order; // Initialize the order property
$this->order = $order;
}
/**
* Execute the job.
*
* This method is called when the job is processed. It checks the status of the order
* and cancels it if it remains unpaid.
*
* @return void
*/
public function handle()
{
// Refresh the order instance from the database to get the latest status
// 查询数据库最新状态
$nowOrder = $this->order->refresh();
// Check if the current status is UN_PAY (unpaid)
// 如果现在还是没有付款,那么则取消订单
if ($nowOrder->status == OrderStatusEnum::UN_PAY) {
// Update the order status to UN_PAY_CANCEL (cancelled due to non-payment)
// 如果订单还是没有付款
// 未付款设置为取消状态,
$this->order->status = OrderStatusEnum::UN_PAY_CANCEL;
$this->order->save(); // Save the updated order status
$this->order->save();
// Process coupon rollback if a coupon was used
// 回退优惠券
if (
!is_null($this->order->coupon_id) && // Ensure a coupon ID exists
$coupon = UserHasCoupon::query()->find($this->order->coupon_id) // Find the coupon in the database
!is_null($this->order->coupon_id) &&
$coupon = UserHasCoupon::query()->find($this->order->coupon_id)
) {
// Reset the coupon usage timestamp
$coupon->used_at = null;
$coupon->save(); // Save changes to the coupon
$coupon->save();
}
// Rollback inventory for each order detail
// 回滚库存
$this->order
->details() // Get the order details
->with('product') // Eager load the associated product
->get() // Fetch the details
->details()
->with('product')
->get()
->map(function (OrderDetail $detail) {
// For each order detail, increment the product's count by the ordered quantity
$product = $detail->product; // Get the associated product
$product->increment('count', $detail->number); // Increase product count
// 不回滚出售数量
$product = $detail->product;
$product->increment('count', $detail->number);
});
}
}

@ -16,29 +16,27 @@ class InstallShopWarn implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $user; // 存储用户实例的属性
protected $user;
/**
* 创建一个新的任务实例。
* Create a new job instance.
*
* @param User $user 用户对象
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user; // 初始化用户属性
$this->user = $user;
}
/**
* 执行任务。
*
* 此方法在处理任务时调用,用于记录网站启动信息。
* Execute the job.
*
* @return void
*/
public function handle()
{
$time = date('Y-m-d H:i:s'); // 获取当前时间
$msg = '网站已启动|启动时间: ' . $time; // 构建日志消息
Log::info($msg); // 将消息记录到日志中
$time = date('Y-m-d H:i:s');
$msg = '网站已启动|启动时间: ' . $time;
Log::info($msg);
}
}

@ -42,8 +42,6 @@ class RemindUsersHasSeckill implements ShouldQueue
// 拿出收藏的用户
$product = $this->seckill->product;
$product->users()
->get()
->map(function (User $user) use ($product) {
@ -52,14 +50,5 @@ class RemindUsersHasSeckill implements ShouldQueue
});
}
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save