From 57cfe70773e02e0025f942b008e8738c6ebe5f73 Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 24 Sep 2020 10:22:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E6=8F=90=E4=B8=8B=E5=8D=95=EF=BC=8C?= =?UTF-8?q?=E6=94=B6=E8=97=8F=EF=BC=8C=E8=AE=A2=E5=8D=95=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/OrderOnlineController.php | 16 ++++++++++++---- .../v3/Implementations/CollectStoreService.php | 18 ++++++++++++------ .../v3/Implementations/OrderOnlineService.php | 14 +++++++++----- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/app/Controller/v3/OrderOnlineController.php b/app/Controller/v3/OrderOnlineController.php index 1fbce79..b068658 100644 --- a/app/Controller/v3/OrderOnlineController.php +++ b/app/Controller/v3/OrderOnlineController.php @@ -110,9 +110,9 @@ class OrderOnlineController extends BaseController $deliveryDistance = config('distance.delivery_distance'); if(isset($distance) && $distance < $deliveryDistance){ if($distance >= 1000){ - $distance_text = '距 ' . bcdiv($distance,1000,2) . 'km'; + $distance_text = '距你收货地址 ' . bcdiv($distance,1000,2) . 'km'; }else{ - $distance_text = '距 ' . $distance . 'm'; + $distance_text = '距你收货地址 ' . $distance . 'm'; } $distributionPrice = $this->distributionPriceService->do($distance); $res['location'] = [ @@ -120,7 +120,8 @@ class OrderOnlineController extends BaseController 'distribution_price' => $distributionPrice, 'distance' => $distance, 'within' => true, - 'distribution_text' => '¥ '.$distributionPrice .'(' .$distance_text .')' + // 'distribution_text' => '¥ '.$distributionPrice .'(' .$distance_text .')' + 'distribution_text' => $distance_text ]; }else{ $res['location'] = [ @@ -132,9 +133,12 @@ class OrderOnlineController extends BaseController ]; } //返回预约送达时间 数组 - $ret = $this->appointmentTimeService->get($shopcartIds); + $ret = $retSelfTake = $this->appointmentTimeService->get($shopcartIds); array_unshift($ret,['title'=>'尽快送达','value'=>'尽快送达']); $res['appointment_time'] = $ret; + + array_unshift($retSelfTake,['title'=>'尽快取货','value'=>'尽快取货']); + $res['appointment_time_self_take'] = $retSelfTake; $res['store_list'] = $this->shopCartService->getGoodsByShopcartId($shopcartIds); //获取用户优惠券 @@ -170,6 +174,10 @@ class OrderOnlineController extends BaseController $total = bcadd($total,$res['value_added_service']['price'],2); $total = bcadd($total,$res['location']['distribution_price'],2); $res['total'] = $total; + + // 新增返回市场信息 + $res['market'] = $market; + return $this->success($res); } diff --git a/app/Service/v3/Implementations/CollectStoreService.php b/app/Service/v3/Implementations/CollectStoreService.php index 8ecbe1d..72e07b0 100644 --- a/app/Service/v3/Implementations/CollectStoreService.php +++ b/app/Service/v3/Implementations/CollectStoreService.php @@ -66,16 +66,22 @@ class CollectStoreService implements CollectStoreServiceInterface //获取用户收藏店铺数量 public function countByUser($userId) { - $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); - $count = $ssdb->exec('get',SsdbKeys::COUNT_COLLECT_STORE_USER.$userId); - return $count; + + return UserCollection::query()->where(['user_id' => $userId])->count(); + + // $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); + // $count = $ssdb->exec('get',SsdbKeys::COUNT_COLLECT_STORE_USER.$userId); + // return $count; } //获取店铺被收藏数量 public function countByStore($storeId) { - $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); - $count = $ssdb->exec('get',SsdbKeys::COUNT_COLLECT_STORE.$storeId); - return $count; + + return UserCollection::query()->where(['store_id' => $storeId])->count(); + + // $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); + // $count = $ssdb->exec('get',SsdbKeys::COUNT_COLLECT_STORE.$storeId); + // return $count; } public function getListByUser($userId) diff --git a/app/Service/v3/Implementations/OrderOnlineService.php b/app/Service/v3/Implementations/OrderOnlineService.php index 57f6a45..1c242ec 100644 --- a/app/Service/v3/Implementations/OrderOnlineService.php +++ b/app/Service/v3/Implementations/OrderOnlineService.php @@ -14,6 +14,7 @@ use App\Exception\ErrorCodeException; use App\Model\v3\Coupon; use App\Model\v3\Goods; use App\Model\v3\GoodsActivity; +use App\Model\v3\Market; use App\Model\v3\Order; use App\Model\v3\OrderGoods; use App\Model\v3\OrderMain; @@ -140,18 +141,21 @@ class OrderOnlineService implements OrderOnlineServiceInterface $shippingType = Shipping::TYPE_SELF_TAKE; // 如果非自提,则通过用户地址计算相关数据和费用 - // if ($selfTake != 1) { + if ($selfTake != 1) { // 用户收货地址 // 获取配送费用 $userAddrAndDPrice = $this->userAddressService->getAddressAndDistributionPrice($userAddrId, $marketId); $userAddr = $userAddrAndDPrice['address']['address']; $deliveryAmount = $userAddrAndDPrice['distribution_price']; $deliveryDistance = $userAddrAndDPrice['delivery_distance']; - // $shippingType = Shipping::TYPE_LANZU; - // } - - if ($selfTake != 1) { $shippingType = Shipping::TYPE_LANZU; + } else { + $market = Market::query()->find($marketId); + $userAddr->tel = $market->tel; + $userAddr->address = $market->address ; + $userAddr->user_name = $market->name; + $userAddr->lat = $market->lat; + $userAddr->lng = $market->lng; } // 优惠券数据,当前订单可用个优惠券