|
|
|
@ -84,32 +84,52 @@ class ShopCartService implements ShopCartServiceInterface |
|
|
|
return mt_rand(0,6); |
|
|
|
} |
|
|
|
|
|
|
|
public function undo() |
|
|
|
public function undo($userId,$marketId) |
|
|
|
{ |
|
|
|
$storeIds = Db::table('lanzu_shopping_cart')->where('user_id',198)->pluck('store_id')->toArray(); |
|
|
|
$res = Store::query()->with(['ShoppingCart' => function($query) { |
|
|
|
$query->with('goods'); |
|
|
|
$storeIds = Db::table('lanzu_shopping_cart')->where([ |
|
|
|
['user_id','=',$userId], |
|
|
|
['market_id','=',$marketId], |
|
|
|
])->pluck('store_id')->toArray(); |
|
|
|
$stores = Store::query()->with(['ShoppingCart' => function($query) use ($userId,$marketId){ |
|
|
|
$query->where([ |
|
|
|
['user_id','=',$userId], |
|
|
|
['market_id','=',$marketId], |
|
|
|
]); |
|
|
|
}])->whereIn('id',$storeIds) |
|
|
|
->get(); |
|
|
|
foreach ($res as &$k){ |
|
|
|
$k->subtotal = '99.90'; |
|
|
|
foreach ($k->ShoppingCart as &$v){ |
|
|
|
switch (mt_rand(1,3)) { |
|
|
|
case 1: |
|
|
|
$str = '已下架'; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
$str = '已抢光'; |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
$str = '已打烊'; |
|
|
|
break; |
|
|
|
} |
|
|
|
$v['goods']['invalid_cause'] = $str; |
|
|
|
->get() |
|
|
|
->toArray(); |
|
|
|
$storeArr = []; |
|
|
|
foreach ($stores as $key => &$store){ |
|
|
|
$sotreType = $this->storeService->check($store['id']); |
|
|
|
if(!$sotreType){ |
|
|
|
unset($stores[$key]); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
$subtotal = 0; |
|
|
|
foreach ($store['shopping_cart'] as &$shopcart){ |
|
|
|
if($shopcart['activity_type'] == 1){ |
|
|
|
$builder = Goods::query(); |
|
|
|
}else{ |
|
|
|
$builder = GoodsActivity::query(); |
|
|
|
} |
|
|
|
return $res; |
|
|
|
$shopcart['goods'] = $builder->where('id',$shopcart['goods_id'])->first()->toArray(); |
|
|
|
foreach ($shopcart['goods'] as $goods){ |
|
|
|
if($shopcart['activity_type'] == 1){ |
|
|
|
$goodsType = $this->goodsService->check($goods['id']); |
|
|
|
}else{ |
|
|
|
$goodsType = $this->goodsActivityService->check($goods['id'],$shopcart['num'],$shopcart['user_id']); |
|
|
|
} |
|
|
|
if($goodsType !== true){ |
|
|
|
unset($shopcart['goods'][$key]); |
|
|
|
continue; |
|
|
|
} |
|
|
|
$subtotal+= $shopcart['num'] * $shopcart['goods']['price']; |
|
|
|
} |
|
|
|
} |
|
|
|
$store['subtotal'] = $subtotal; |
|
|
|
$storeArr[] = $store; |
|
|
|
} |
|
|
|
return $storeArr; |
|
|
|
} |
|
|
|
|
|
|
|
public function countGoods() |
|
|
|
|