Browse Source

购物车

master
weigang 5 years ago
parent
commit
8350701295
  1. 2
      app/Controller/v3/OrderOnlineController.php
  2. 6
      app/Service/v3/Implementations/CouponRecService.php
  3. 11
      app/Service/v3/Implementations/ShopCartService.php
  4. 2
      app/Service/v3/Interfaces/CouponRecServiceInterface.php
  5. 2
      app/Service/v3/Interfaces/ShopCartServiceInterface.php

2
app/Controller/v3/OrderOnlineController.php

@ -142,7 +142,7 @@ class OrderOnlineController extends BaseController
$res['store_list'] = $this->shopCartService->getGoodsByShopcartId($shopcartIds);
//获取用户优惠券
$coupons = $this->couponRecService->allForOnlineOrderAvailable($userId, $marketId);
$coupons = $this->couponRecService->allForOnlineOrderAvailable($userId, $marketId, $shopcartIds);
$res['coupon'] = [
'available' => [],
'not_available' => [],

6
app/Service/v3/Implementations/CouponRecService.php

@ -144,11 +144,13 @@ class CouponRecService implements CouponRecServiceInterface
* 4、筛选出其中活动商品可用但商品的活动类型不符合优惠券活动使用类型的要求(订单中有活动商品可以用优惠券,但是活动类型type和优惠券中的available活动类型不可用)
* @param $userId
* @param $marketId
* @param $shopcartIds
* @return array
*/
public function allForOnlineOrderAvailable($userId, $marketId)
public function allForOnlineOrderAvailable($userId, $marketId, $shopcartIds)
{
// 获取购物车数据
$carts = $this->shopCartService->allForUser($userId, $marketId);
$carts = $this->shopCartService->allForUser($userId, $marketId, $shopcartIds);
$totalAmount = $carts['total'];
// 获取购物车中商品和店铺的类别

11
app/Service/v3/Implementations/ShopCartService.php

@ -232,9 +232,10 @@ class ShopCartService implements ShopCartServiceInterface
* 获取用户购物车数据
* @param $userId
* @param $marketId
* @param array $shopcartIds
* @return array
*/
public function allForUser($userId, $marketId)
public function allForUser($userId, $marketId, $shopcartIds = [])
{
bcscale(6);
@ -246,8 +247,12 @@ class ShopCartService implements ShopCartServiceInterface
}
])
->where(['user_id' => $userId])
->where(['market_id' => $marketId])
->get();
->where(['market_id' => $marketId]);
if (!empty($carts)) {
$carts = $carts->whereIn('id', $shopcartIds);
}
$carts = $carts->get();
$cartList = [];
$totalAmount = 0;
foreach ($carts as $key => &$cart) {

2
app/Service/v3/Interfaces/CouponRecServiceInterface.php

@ -9,7 +9,7 @@ interface CouponRecServiceInterface
public function undo();
public function allForOrderOlAvailable($totalAmount,$userId,$marketId,$type,$storeTypeId);
public function getListByUser($userId,$type,$page = 1,$pagesize = 5);
public function allForOnlineOrderAvailable($userId, $marketId);
public function allForOnlineOrderAvailable($userId, $marketId, $shopcartIds);
/**
* 统计用户可使用优惠券数量
* @param $userId

2
app/Service/v3/Interfaces/ShopCartServiceInterface.php

@ -16,5 +16,5 @@ interface ShopCartServiceInterface
public function getGoodsByShopcartId($shopcartIds);
public function allForUser($userId, $marketId);
public function allForUser($userId, $marketId, $shopcartIds = []);
}
Loading…
Cancel
Save