Browse Source

自提下单,收藏,订单确认页

master
weigang 5 years ago
parent
commit
57cfe70773
  1. 16
      app/Controller/v3/OrderOnlineController.php
  2. 18
      app/Service/v3/Implementations/CollectStoreService.php
  3. 14
      app/Service/v3/Implementations/OrderOnlineService.php

16
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);
}

18
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)

14
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;
}
// 优惠券数据,当前订单可用个优惠券

Loading…
Cancel
Save