From d9806a96cbf6497fce7d6471ad803f0ddaf21574 Mon Sep 17 00:00:00 2001 From: yin5th <541304803@qq.com> Date: Fri, 13 Oct 2023 14:10:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=BC=E5=AE=B9is=5Fapi=3D1=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=9B=B4=E6=8E=A5=E5=9C=B0=E5=9D=80=E4=B8=8B=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app/api/logic/OrderLogic.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/server/app/api/logic/OrderLogic.php b/server/app/api/logic/OrderLogic.php index 5d56bc91..c9f8f757 100644 --- a/server/app/api/logic/OrderLogic.php +++ b/server/app/api/logic/OrderLogic.php @@ -110,11 +110,27 @@ class OrderLogic extends Logic if (false === $check_goods) { throw new Exception(self::$error); } - $address = UserAddress::where('id', $post['address_id']) - ->field('contact,telephone,province_id,city_id,district_id,address') - ->find(); - if (empty($address)) { - throw new Exception('请选择地址'); + + $address = []; + // is_api接口 + if (!empty($post['is_api']) && $post['is_api'] == 1) { + if (empty($post['contact']) || empty($post['province_id']) || empty($post['city_id']) + || empty($post['district_id']) || empty($post['address']) || empty($post['telephone'])) { + throw new Exception('请填写收货信息'); + } + $address['contact'] = $post['contact']; + $address['province_id'] = $post['province_id']; + $address['city_id'] = $post['city_id']; + $address['district_id'] = $post['district_id']; + $address['address'] = $post['address']; + $address['telephone'] = $post['telephone']; + } else { + $address = UserAddress::where('id', $post['address_id']) + ->field('contact,telephone,province_id,city_id,district_id,address') + ->find(); + if (empty($address)) { + throw new Exception('请选择地址'); + } } // 校验发票信息 返回以店铺id为键,原发票参数为值的数组 @@ -919,12 +935,14 @@ class OrderLogic extends Logic $order_data['pay_way'] = $post['pay_way']; $order_data['delivery_type'] = $post['delivery_type'] ?? 0; $order_data['aftersale_status'] = OrderEnum::AFTERSALE_STATUS_NO_SALE; + $order_data['consignee'] = $address['contact']; $order_data['province'] = $address['province_id']; $order_data['city'] = $address['city_id']; $order_data['district'] = $address['district_id']; $order_data['address'] = $address['address']; $order_data['mobile'] = $address['telephone']; + $order_data['goods_price'] = $goods_price; $order_data['shipping_price'] = $shipping_price; $order_data['order_amount'] = $order_amount;