feat : order

This commit is contained in:
2025-03-04 16:26:14 +08:00
parent 8b67fccf64
commit 902ffa5f1f

View File

@@ -16,6 +16,7 @@ use Hyperf\Amqp\Message\Type;
use Hyperf\Amqp\Result;
use Hyperf\Amqp\Annotation\Consumer;
use Hyperf\Amqp\Message\ConsumerMessage;
use Hyperf\DbConnection\Db;
use Hyperf\Di\Annotation\Inject;
use PhpAmqpLib\Message\AMQPMessage;
use Psr\Container\ContainerExceptionInterface;
@@ -112,7 +113,7 @@ class OrderGoodStockConsumer extends ConsumerMessage
return Result::ACK;
}
if (!(new Sku)->update($this->updateArr)) {
if (!(Db::table('sku')->update($this->updateArr))) {
$this->log->debug('OrderGoodStockConsumer:error:UpdateSkuDataFail:'.json_encode($this->updateArr));
return Result::ACK;
}
@@ -133,7 +134,7 @@ class OrderGoodStockConsumer extends ConsumerMessage
$this->updateArr[] = [
'id' => $orderGood['sku_id'],
'sales_num' => ($this->skuArr[$orderGood['sku_id']]['sales_num'] ?? 0) + $orderGood['quantity'],
'order_num' => ($this->skuArr[$orderGood['sku_id']]['order_num'] ?? 0) + 1,
'order_num' => ($this->skuArr[$orderGood['sku_id']]['order_num'] ?? 0) + $orderGood['quantity'],
'surplus_stock' => ($this->skuArr[$orderGood['sku_id']]['surplus_stock'] ?? 0) - $orderGood['quantity'],
];
}
@@ -152,7 +153,7 @@ class OrderGoodStockConsumer extends ConsumerMessage
$this->updateArr[] = [
'id' => $orderGood['sku_id'],
'refund_num' => ($this->skuArr[$orderGood['sku_id']]['refund_num'] ?? 0) + $orderGood['quantity'],
'order_num' => ($this->skuArr[$orderGood['sku_id']]['order_num'] ?? 0) - 1,
'order_num' => ($this->skuArr[$orderGood['sku_id']]['order_num'] ?? 0) - $orderGood['quantity'],
'surplus_stock' => ($this->skuArr[$orderGood['sku_id']]['surplus_stock'] ?? 0) + $orderGood['quantity'],
];
}
@@ -167,7 +168,7 @@ class OrderGoodStockConsumer extends ConsumerMessage
$this->updateArr[] = [
'id' => $orderGood['sku_id'],
'cancel_num' => ($this->skuArr[$orderGood['sku_id']]['cancel_num'] ?? 0) + $orderGood['quantity'],
'order_num' => ($this->skuArr[$orderGood['sku_id']]['order_num'] ?? 0) - 1,
'order_num' => ($this->skuArr[$orderGood['sku_id']]['order_num'] ?? 0) - $orderGood['quantity'],
'surplus_stock' => ($this->skuArr[$orderGood['sku_id']]['surplus_stock'] ?? 0) + $orderGood['quantity'],
];
}