$this->mall_id, 'user_id' => $this->user_id, 'status' => StatusEnum::ENABLED] ]; if ($goodsIds) { $where[] = ['goods_id' => $goodsIds]; } return CloudStockFillCart::lists( [ 'where' => $where, 'select' => 'goods_id, num' ] ); } /** * 购物车转为订单 * * @return void */ public function cart2Order(int $orderId) { CloudStockFillCart::updateAll( [ 'status' => StatusEnum::DISABLED, 'order_id' => $orderId, 'updated_at' => time() ], [ 'user_id' => $this->user_id, 'mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, ] ); } /** * 返回购物车汇总信息 * * @return array */ public function getCartInfo(): array { $res = [ 'cart_list' => [], 'replenish_price' => 0, 'profit' => 0, ]; $cartList = $this->getCartList(); if (empty($cartList)) { return $res; } $res['cart_list'] = $cartList; $goodsPriceList = (new CloudStockGoodsService(['mall_id' => $this->mall_id, 'user_id' => $this->user_id, 'stock_agent' => $this->stock_agent])) ->getGoodsPrice($cartList); $res['replenish_price'] = $goodsPriceList['replenish_price']; $res['profit'] = $goodsPriceList['profit']; return $res; } }