Cart.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\common\model;
  13. use cores\BaseModel;
  14. /**
  15. * 模型类:购物车
  16. * Class Cart
  17. * @package app\common\model
  18. */
  19. class Cart extends BaseModel
  20. {
  21. // 定义表名
  22. protected $name = 'cart';
  23. // 定义主键
  24. protected $pk = 'id';
  25. /**
  26. * 详情记录
  27. * @param int $userId 用户ID
  28. * @param int $goodsId 商品ID
  29. * @param string $goodsSkuId 商品sku唯一标识
  30. * @return array|static|null
  31. * @throws \think\db\exception\DataNotFoundException
  32. * @throws \think\db\exception\DbException
  33. * @throws \think\db\exception\ModelNotFoundException
  34. */
  35. public static function detail(int $userId, int $goodsId, string $goodsSkuId)
  36. {
  37. return (new static)->where('user_id', '=', $userId)
  38. ->where('goods_id', '=', $goodsId)
  39. ->where('goods_sku_id', '=', $goodsSkuId)
  40. ->where('is_delete', '=', 0)
  41. ->find();
  42. }
  43. }