From 0842541d4defa1a0f2dec2cbe4876cdb9b7d49c2 Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Wed, 28 Feb 2024 14:13:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=B7=BB=E5=8A=A0=E6=88=90?= =?UTF-8?q?=E6=9C=AC=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/service/order/Checkout.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/api/service/order/Checkout.php b/app/api/service/order/Checkout.php index af78868e..5746aff4 100644 --- a/app/api/service/order/Checkout.php +++ b/app/api/service/order/Checkout.php @@ -731,7 +731,7 @@ class Checkout extends BaseService // 新增订单记录 $this->add($order, $this->param['remark']); // 保存订单数据 (根据订单类型) - $order['orderType'] == 10 && $this->saveOrderByPhysical($order); + $order['orderType'] == OrderType::PHYSICAL && $this->saveOrderByPhysical($order); // 保存订单商品信息 $this->saveOrderGoods($order); // 更新商品库存 (针对下单减库存的商品) @@ -853,6 +853,8 @@ class Checkout extends BaseService 'expect_receive_time' => $this->param['expect_receive_time'],//期待收货时间 'is_street_take' => $this->param['is_street_take'],//是否街边1-在 0-不在 'to_store_time' => $this->param['to_store_time'],//预计到店时间 + //添加成本价 + 'cost_price' => $this->getCostPrice($order['goodsList']), ]; if ($order['delivery'] == DeliveryTypeEnum::EXPRESS) { $data['express_price'] = $order['expressPrice']; @@ -863,6 +865,15 @@ class Checkout extends BaseService $this->model->save($data); } + public function getCostPrice($goodsList): string + { + $totalCostPrice = 0; + foreach ($goodsList as $goods) { + $totalCostPrice +=$goods['skuInfo']['cost_price']; + } + return helper::number2($totalCostPrice); + } + /** * 保存订单商品信息 * @param $order @@ -909,6 +920,8 @@ class Checkout extends BaseService 'first_money' => $goods['first_money'], 'second_money' => $goods['second_money'], 'third_money' => $goods['third_money'], + //添加成本价 + 'cost_price' => $goods['skuInfo']['cost_price'], ]; // 记录订单商品来源ID $item['goods_source_id'] = isset($goods['goods_source_id']) ? $goods['goods_source_id'] : 0;