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;