IntegralGoodsLogic.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\shopapi\logic;
  3. use app\common\logic\BaseLogic;
  4. use app\common\model\IntegralGoods;
  5. use app\common\model\User;
  6. use app\shopapi\lists\IntegralGoodsLists;
  7. /**
  8. * 积分商品逻辑
  9. * Class IntegralGoodsLogic
  10. * @package app\api\logic
  11. */
  12. class IntegralGoodsLogic extends BaseLogic
  13. {
  14. /**
  15. * @notes 积分商品列表
  16. * @param $userId
  17. * @return array
  18. * @throws \think\db\exception\DataNotFoundException
  19. * @throws \think\db\exception\DbException
  20. * @throws \think\db\exception\ModelNotFoundException
  21. * @author 段誉
  22. * @date 2022/3/31 9:49
  23. */
  24. public static function lists($userId)
  25. {
  26. $integral = User::findOrEmpty($userId);
  27. $goods = (new IntegralGoodsLists());
  28. return [
  29. 'integral' => $integral['user_integral'] ?? 0,
  30. 'goods' => [
  31. 'lists' => $goods->lists(),
  32. 'count' => $goods->count(),
  33. 'page_no' => $goods->pageNo,
  34. 'page_size' => $goods->pageSize,
  35. 'more' => is_more($goods->count(), $goods->pageNo, $goods->pageSize)
  36. ]
  37. ];
  38. }
  39. /**
  40. * @notes 商品详情
  41. * @param $params
  42. * @return array
  43. * @author 段誉
  44. * @date 2022/3/31 9:49
  45. */
  46. public static function detail($params)
  47. {
  48. return IntegralGoods::where(['id' => $params['id']])->findOrEmpty()->toArray();
  49. }
  50. }