From a034ae5ec119433c1dc0495fd3b0491102a6cd43 Mon Sep 17 00:00:00 2001 From: "DESKTOP-GMUNQ1B\\Administrator" <604446095@qq.com> Date: Fri, 6 Dec 2024 13:40:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=84=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreProductPriceLists.php | 3 +- .../beforehand_order/BeforehandOrderLogic.php | 7 ++++ app/common/model/geo/GeoArea.php | 16 +++++++++ app/common/model/geo/GeoBrigade.php | 16 +++++++++ app/common/model/geo/GeoCity.php | 16 +++++++++ app/common/model/geo/GeoProvince.php | 16 +++++++++ app/common/model/geo/GeoStreet.php | 16 +++++++++ app/common/model/geo/GeoVillage.php | 16 +++++++++ app/common/model/user/UserAddress.php | 33 +++++++++++++++++++ 9 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 app/common/model/geo/GeoArea.php create mode 100644 app/common/model/geo/GeoBrigade.php create mode 100644 app/common/model/geo/GeoCity.php create mode 100644 app/common/model/geo/GeoProvince.php create mode 100644 app/common/model/geo/GeoStreet.php create mode 100644 app/common/model/geo/GeoVillage.php diff --git a/app/admin/lists/store_product_price/StoreProductPriceLists.php b/app/admin/lists/store_product_price/StoreProductPriceLists.php index 7995c7d8..2294db79 100644 --- a/app/admin/lists/store_product_price/StoreProductPriceLists.php +++ b/app/admin/lists/store_product_price/StoreProductPriceLists.php @@ -52,7 +52,8 @@ class StoreProductPriceLists extends BaseAdminDataLists implements ListsSearchIn ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ - $find = StoreProduct::where('id', $item['product_id'])->field('image,store_name,store_info')->find(); + $find = StoreProduct::with('unitName')->where('id', $item['product_id'])->field('image,store_name,store_info,unit')->find(); + $item['unit_name']=$find['unitName']['name']; $item['store_name']=$find['store_name']; $item['store_info']=$find['store_info']; $item['image']=$find['image']; diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 6d19a2b0..f6c83cf4 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -70,6 +70,13 @@ class BeforehandOrderLogic extends BaseLogic $total_num = 0; $total_price = 0; $uid = $params['uid'] ?? 0; + if (!empty($uid) && empty($params['other_data']['nickname'])) { + $user = User::where('id', $uid)->field('nickname,mobile')->find(); + $userAddress = UserAddress::getDefaultAddress($uid); + $params['other_data']['nickname'] = $user['nickname']; + $params['other_data']['phone'] = $user['mobile']; + $params['other_data']['address'] = !empty($userAddress) ? $userAddress['area']['area_name'] . $userAddress['street']['street_name'] . $userAddress['village']['village_name'] . $userAddress['brigade']['brigade_name'] . $userAddress['detail'] : ''; + } foreach ($params['product_arr'] as $k => $v) { if ($v['product_id'] <= 0) { unset($params['product_arr'][$k]); diff --git a/app/common/model/geo/GeoArea.php b/app/common/model/geo/GeoArea.php new file mode 100644 index 00000000..cb0741e9 --- /dev/null +++ b/app/common/model/geo/GeoArea.php @@ -0,0 +1,16 @@ +where(['uid' => $uid, 'is_default' => 1])->find(); + if (empty($address)) { + $address = self::with(['area', 'street', 'village', 'brigade'])->where(['uid' => $uid])->find(); + } + return empty($address) ? [] : $address->toArray(); + } + + public function area() + { + return $this->hasOne(GeoArea::class, 'area_code', 'area')->field('area_code,area_name'); + } + + public function street() + { + return $this->hasOne(GeoStreet::class, 'street_code', 'street')->field('street_code,street_name'); + } + + public function village() + { + return $this->hasOne(GeoVillage::class, 'village_code', 'village')->field('village_code,village_name'); + } + + public function brigade() + { + return $this->hasOne(GeoBrigade::class, 'id', 'brigade')->field('id,brigade_name'); + } + } \ No newline at end of file