From a0bc9222074fc06c93fba56f92bfc738e7529984 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 28 Sep 2024 09:24:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E4=BA=86=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=9B=B8=E5=85=B3=E7=9A=84API=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E7=A7=BB=E9=99=A4=E4=BA=86=E4=B8=8D=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E7=9A=84=E7=BB=8F=E7=BA=AC=E5=BA=A6=E5=8F=82=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E4=BA=86=E6=88=90=E6=9C=AC=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E6=96=B9=E5=BC=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 8 +----- app/api/logic/order/OrderLogic.php | 26 +++----------------- app/common/logic/PayNotifyLogic.php | 2 +- 3 files changed, 6 insertions(+), 30 deletions(-) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 3a126f617..9b0e7b86c 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -339,18 +339,12 @@ class OrderController extends BaseApiController public function detail() { $order_id = (int)$this->request->get('order_id'); - $lat = $this->request->get('lat', ''); - $lng = $this->request->get('long', ''); $where = [ 'id' => $order_id, 'uid' => $this->userId, ]; $url = 'https://' . $this->request->host(true); - $parm = [ - 'lat' => $lat, - 'long' => $lng - ]; - $order = OrderLogic::detail($where, $url, $parm); + $order = OrderLogic::detail($where, $url); if ($order) { return $this->data($order); } else { diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 046e50d24..c420d9581 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -149,7 +149,7 @@ class OrderLogic extends BaseLogic //利润 // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 - $cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本 + $cart_select[$k]['total_purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本 $cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $price, 2); //订单支付金额 $cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //商户价 $cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2) ?? 0; //vip售价 @@ -181,13 +181,14 @@ class OrderLogic extends BaseLogic $cart_select[$k]['cart_info'] = json_encode($cartInfo); //理论上每笔都是拆分了 $cart_select[$k]['name'] = $find['store_name']; + $cart_select[$k]['purchase'] = $find['purchase']; $cart_select[$k]['imgs'] = $find['image']; $cart_select[$k]['store_id'] = $params['store_id'] ?? 0; $cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name'); $cart_select[$k]['total_price'] = $cart_select[$k]['pay_price']; self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2); self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2); - self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2); + self::$cost = bcadd(self::$cost, $cart_select[$k]['total_purchase'], 2); self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //商户价 self::$deduction_price = bcadd(self::$deduction_price, $deduction_price, 2); //抵扣金额 // self::$frozen_money = bcadd(self::$frozen_money, $cart_select[$k]['vip_frozen_price'], 2); //返还金额 @@ -343,7 +344,6 @@ class OrderLogic extends BaseLogic $goods_list[$k]['oid'] = $order->id; $goods_list[$k]['uid'] = $uid; $goods_list[$k]['cart_id'] = implode(',', $cartId); - $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id } (new StoreOrderCartInfo())->saveAll($goods_list); $where = ['is_pay' => 0]; @@ -500,13 +500,11 @@ class OrderLogic extends BaseLogic if ($find) { $find['goods_list'] = StoreOrderCartInfo::where('oid', $find['id']) - ->field('product_id,cart_num nums,store_id')->select()->each(function ($item) use ($find) { + ->field('product_id,cart_num nums,store_id,price')->select()->each(function ($item) { $find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find(); - $item['store_name'] = $find['store_name']; $item['nums'] = floatval($item['nums']); $item['image'] = $find['image']; - $item['price'] = $find['price']; $item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? ''; $item['msg'] = '预计48小时发货'; return $item; @@ -523,22 +521,6 @@ class OrderLogic extends BaseLogic $tmpFilename = $generator->getBarcode($find['verify_code'], $generator::TYPE_CODE_128); $find['verify_base64'] = 'data:image/png;base64,' . base64_encode($tmpFilename); } - //处理返回最近的店铺 - if ($param['lat'] && $param['long']) { - $storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray(); - $nearestStore = null; - $minDistance = PHP_FLOAT_MAX; - foreach ($storeAll as $value) { - $value['distance'] = haversineDistance($value['latitude'], $value['longitude'], $param['lat'], $param['long']); - if ($value['distance'] < $minDistance) { - $minDistance = $value['distance']; - $nearestStore = $value; - } - } - if ($nearestStore) { - $find['near_store'] = $nearestStore; - } - } } return $find; } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index ae5f8b2c2..2647d6275 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -684,7 +684,7 @@ class PayNotifyLogic extends BaseLogic } try { - $info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,price,cart_num')->select(); + $info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,price,purchase,cart_num')->select(); $comm = new CommissionProductLogic(); foreach ($info as $k => $v) { $comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid, $user_ship);