Cart.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. /**
  14. * 模型类:购物车
  15. * Class Cart
  16. * @package app\common\model
  17. */
  18. class Cart extends BaseModel
  19. {
  20. // 定义表名
  21. protected $name = 'cart';
  22. // 定义主键
  23. protected $pk = 'id';
  24. /**
  25. * 详情记录
  26. * @param int $userId 用户ID
  27. * @param int $goodsId 商品ID
  28. * @param string $goodsSkuId 商品sku唯一标识
  29. * @return array|static|null
  30. * @throws \think\db\exception\DataNotFoundException
  31. * @throws \think\db\exception\DbException
  32. * @throws \think\db\exception\ModelNotFoundException
  33. */
  34. public static function detail(int $userId, int $goodsId, string $goodsSkuId)
  35. {
  36. return (new static)->where('user_id', '=', $userId)
  37. ->where('goods_id', '=', $goodsId)
  38. ->where('goods_sku_id', '=', $goodsSkuId)
  39. ->where('is_delete', '=', 0)
  40. ->find();
  41. }
  42. }