diff --git a/app/Cache/Redis/Api/GoodCache.php b/app/Cache/Redis/Api/GoodCache.php index d83e0fd..ebde0b9 100644 --- a/app/Cache/Redis/Api/GoodCache.php +++ b/app/Cache/Redis/Api/GoodCache.php @@ -104,8 +104,8 @@ class GoodCache $stockKey = ApiRedisKey::goodStockKey($this->cycleId,$this->kitchenId); foreach ($this->stockArr as $one) { $this->redis->zAdd($stockKey,$one['stock'],$one['id']); - $this->redis->expire($stockKey,$this->expireTime); } + $this->redis->expire($stockKey,$this->expireTime); } } @@ -167,7 +167,7 @@ class GoodCache } if (!empty($stockArr)) { - $this->stockArr = $stockArr; + $this->stockArr = array_merge($this->stockArr,$stockArr); } foreach ($list as &$item) { diff --git a/app/Event/PayGoodOrderFinishEvent.php b/app/Event/PayGoodOrderFinishEvent.php new file mode 100644 index 0000000..89eb91f --- /dev/null +++ b/app/Event/PayGoodOrderFinishEvent.php @@ -0,0 +1,28 @@ +orderId = $orderId; + $this->payOrderId = $payOrderId; + } +} diff --git a/app/Event/RefundGoodOrderFinishEvent.php b/app/Event/RefundGoodOrderFinishEvent.php new file mode 100644 index 0000000..e7330d3 --- /dev/null +++ b/app/Event/RefundGoodOrderFinishEvent.php @@ -0,0 +1,35 @@ +orderId = $orderId; + $this->payOrderId = $payOrderId; + $this->refundOrderId = $refundOrderId; + } +} diff --git a/app/Listener/RefundGoodOrderFinishRollBackCouponListener.php b/app/Listener/RefundGoodOrderFinishRollBackCouponListener.php new file mode 100644 index 0000000..eaed076 --- /dev/null +++ b/app/Listener/RefundGoodOrderFinishRollBackCouponListener.php @@ -0,0 +1,64 @@ +refundOrderModel + ->where('order_id',$event->orderId) + ->where('type',RefundCode::FULL_GOOD_REFUND) + ->where('refund_status',RefundCode::REFUND_SUCCESS) + ->count() ?? 0; + + if ($isAll <= 0) return; + + $orderInfo = $this->orderModel->find($event->orderId); + + if (empty($orderInfo)) return; + + if ($orderInfo->status != OrderCode::FINISH_REFUND) return; + + if ($orderInfo->coupon_id <= 0) return; + + $this->rollbackCoupon(OrderCode::ORDER_TYPE_GOOD,$orderInfo); + } catch (Exception $e) { + $this->log->error(__CLASS__.'RefundGoodOrderFinishRollBackCouponListener:error:'. $e->getMessage()); + } + } +} diff --git a/app/Listener/RefundGoodOrderFinishStatementListener.php b/app/Listener/RefundGoodOrderFinishStatementListener.php new file mode 100644 index 0000000..83d0ea7 --- /dev/null +++ b/app/Listener/RefundGoodOrderFinishStatementListener.php @@ -0,0 +1,77 @@ +refundOrderModel->find($event->refundOrderId); + if (empty($refundOrderInfo) || $refundOrderInfo->status != RefundCode::REFUND_SUCCESS) throw new Exception('退款信息不存在'); + + $this->orderInfo = $this->orderModel->find($event->orderId); + if (empty($this->orderInfo) || !in_array($this->orderInfo->status,[OrderCode::FINISH_REFUND,OrderCode::UNCOMPLETED_REFUND])) throw new Exception('订单信息不存在'); + + $this->orderGoodIds = $this->orderGoodModel->where('order_id',$event->orderId)->pluck('id')->toArray(); + if (empty($this->orderGoodIds)) throw new Exception('订单商品信息不存在'); + + $this->rollBackChefData(); + + $this->rollBackFinancesData(); + } catch (Exception $e) { + $this->log->error(__CLASS__.':退款完成后生成订单结算数据失败:'.$e->getMessage()); + } + } + + private function rollBackChefData(): void + { + + } + + private function rollBackFinancesData(): void + { + + } +}