StoreBargainUserHelpDao.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types=1);
  12. namespace app\dao\activity\bargain;
  13. use app\dao\BaseDao;
  14. use app\model\activity\bargain\StoreBargainUserHelp;
  15. /**
  16. *
  17. * Class StoreBargainUserHelpDao
  18. * @package app\dao\activity
  19. */
  20. class StoreBargainUserHelpDao extends BaseDao
  21. {
  22. /**
  23. * 设置模型
  24. * @return string
  25. */
  26. protected function setModel(): string
  27. {
  28. return StoreBargainUserHelp::class;
  29. }
  30. /**
  31. * 获取帮砍人数
  32. * @return array
  33. */
  34. public function getHelpAllCount(array $where = [])
  35. {
  36. return $this->getModel()->where($where)->group('bargain_id')->column('count(*)', 'bargain_id');
  37. }
  38. /**
  39. * 获取帮砍列表
  40. * @param int $bid
  41. * @param int $page
  42. * @param int $limit
  43. * @return array
  44. */
  45. public function getHelpList(int $bid, int $page = 0, int $limit = 0)
  46. {
  47. return $this->getModel()
  48. ->where('bargain_user_id', $bid)
  49. ->order('add_time desc')
  50. ->when($page, function ($query) use ($page, $limit) {
  51. $query->page($page, $limit);
  52. })->column("uid,price,from_unixtime(add_time,'%Y-%m-%d %H:%i:%s') as add_time", 'id');
  53. }
  54. /**
  55. * 获取砍价商品已砍人数
  56. * @return array
  57. */
  58. public function getNums()
  59. {
  60. return $this->getModel()->field('count(id) as num,bargain_user_id')->group('bargain_user_id')->select()->toArray();
  61. }
  62. }