feat : order
This commit is contained in:
@@ -16,6 +16,7 @@ use Hyperf\Amqp\Message\Type;
|
|||||||
use Hyperf\Amqp\Result;
|
use Hyperf\Amqp\Result;
|
||||||
use Hyperf\Amqp\Annotation\Consumer;
|
use Hyperf\Amqp\Annotation\Consumer;
|
||||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||||
|
use Hyperf\DbConnection\Db;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
use PhpAmqpLib\Message\AMQPMessage;
|
use PhpAmqpLib\Message\AMQPMessage;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
@@ -112,7 +113,7 @@ class OrderGoodStockConsumer extends ConsumerMessage
|
|||||||
return Result::ACK;
|
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));
|
$this->log->debug('OrderGoodStockConsumer:error:UpdateSkuDataFail:'.json_encode($this->updateArr));
|
||||||
return Result::ACK;
|
return Result::ACK;
|
||||||
}
|
}
|
||||||
@@ -133,7 +134,7 @@ class OrderGoodStockConsumer extends ConsumerMessage
|
|||||||
$this->updateArr[] = [
|
$this->updateArr[] = [
|
||||||
'id' => $orderGood['sku_id'],
|
'id' => $orderGood['sku_id'],
|
||||||
'sales_num' => ($this->skuArr[$orderGood['sku_id']]['sales_num'] ?? 0) + $orderGood['quantity'],
|
'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'],
|
'surplus_stock' => ($this->skuArr[$orderGood['sku_id']]['surplus_stock'] ?? 0) - $orderGood['quantity'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -152,7 +153,7 @@ class OrderGoodStockConsumer extends ConsumerMessage
|
|||||||
$this->updateArr[] = [
|
$this->updateArr[] = [
|
||||||
'id' => $orderGood['sku_id'],
|
'id' => $orderGood['sku_id'],
|
||||||
'refund_num' => ($this->skuArr[$orderGood['sku_id']]['refund_num'] ?? 0) + $orderGood['quantity'],
|
'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'],
|
'surplus_stock' => ($this->skuArr[$orderGood['sku_id']]['surplus_stock'] ?? 0) + $orderGood['quantity'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -167,7 +168,7 @@ class OrderGoodStockConsumer extends ConsumerMessage
|
|||||||
$this->updateArr[] = [
|
$this->updateArr[] = [
|
||||||
'id' => $orderGood['sku_id'],
|
'id' => $orderGood['sku_id'],
|
||||||
'cancel_num' => ($this->skuArr[$orderGood['sku_id']]['cancel_num'] ?? 0) + $orderGood['quantity'],
|
'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'],
|
'surplus_stock' => ($this->skuArr[$orderGood['sku_id']]['surplus_stock'] ?? 0) + $orderGood['quantity'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user