feat : order

This commit is contained in:
2025-03-04 16:20:42 +08:00
parent 3dcb545952
commit 8b67fccf64
2 changed files with 2 additions and 1 deletions

View File

@@ -83,6 +83,7 @@ class OrderGoodStockConsumer extends ConsumerMessage
$this->skuArr = []; $this->skuArr = [];
$this->orderGoodArr = $this->orderGoodModel->getGoodIdsByOrderId($orderId); $this->orderGoodArr = $this->orderGoodModel->getGoodIdsByOrderId($orderId);
$this->log->debug('OrderGoodStockConsumer:'.json_encode($this->orderGoodArr));
if (empty($this->orderGoodArr)) { if (empty($this->orderGoodArr)) {
$this->log->debug('OrderGoodStockConsumer:error:NoOrderGoodData:'.json_encode($orderId)); $this->log->debug('OrderGoodStockConsumer:error:NoOrderGoodData:'.json_encode($orderId));
return Result::ACK; return Result::ACK;

View File

@@ -50,6 +50,6 @@ class OrderGood extends Model
*/ */
public function getGoodIdsByOrderId(int $orderId): array public function getGoodIdsByOrderId(int $orderId): array
{ {
return $this->where('order_id', $orderId)->select('sku_id')->selectRaw('SUM(`quantity`) as `quantity`')->get()->toArray(); return $this->where('order_id', $orderId)->select('sku_id')->selectRaw('SUM(`quantity`) as `quantity`')->groupBy('sku_id')->get()->toArray();
} }
} }