You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.1 KiB

6 years ago
  1. <?php
  2. namespace App\Service\v3\Implementations;
  3. use App\Model\v3\ShoppingCart;
  4. use App\Model\v3\Store;
  5. use App\Service\v3\Interfaces\ShopCartServiceInterface;
  6. use Hyperf\DbConnection\Db;
  7. class ShopCartService implements ShopCartServiceInterface
  8. {
  9. public function do()
  10. {
  11. $storeIds = Db::table('lanzu_shopping_cart')->where('user_id',15)->pluck('store_id')->toArray();
  12. $res = Store::query()->with(['ShoppingCart' => function($query) {
  13. $query->with('goods');
  14. }])->whereIn('id',$storeIds)
  15. ->get();
  16. return $res;
  17. }
  18. public function check($goodsId)
  19. {
  20. return mt_rand(0,6);
  21. }
  22. public function undo()
  23. {
  24. $storeIds = Db::table('lanzu_shopping_cart')->where('user_id',198)->pluck('store_id')->toArray();
  25. $res = Store::query()->with(['ShoppingCart' => function($query) {
  26. $query->with('goods');
  27. }])->whereIn('id',$storeIds)
  28. ->get();
  29. return $res;
  30. }
  31. public function countGoods()
  32. {
  33. return mt_rand(1,100);
  34. }
  35. }