GroupBuyJoin.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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\store\model\groupbuy;
  13. use app\common\model\groupbuy\GroupBuyJoin as GroupBuyJoinModel;
  14. use app\common\library\helper;
  15. /**
  16. * 拼团发起模型
  17. * Class Coupon
  18. * @package app\store\model
  19. */
  20. class GroupBuyJoin extends GroupBuyJoinModel
  21. {
  22. protected $append = [];
  23. /**
  24. * @param $activityId
  25. * @return \think\Paginator
  26. * @throws \think\db\exception\DbException
  27. */
  28. public function getList($activityId){
  29. return self::alias('gj')->leftJoin('user us','gj.user_id=us.user_id')
  30. ->field('us.nick_name,gj.id,gj.group_buy_activity_id,gj.people_count,gj.end_time,gj.status,gj.user_id,
  31. gj.share_title,gj.create_time,(select count(id) from yoshop_group_buy_activity_help where join_id=gj.id and
  32. pay_state=1 and order_id >=0) as help_count')
  33. ->where('gj.group_buy_activity_id',$activityId)
  34. ->where('gj.status','<>',3)
  35. ->paginate(15);
  36. }
  37. /**
  38. * 活动参团人数
  39. * @param $activityId
  40. * @return int
  41. */
  42. public function sumActHelpCount($activityId){
  43. return self::where('group_buy_activity_id',$activityId)->sum('help_count');
  44. }
  45. /**
  46. * 活动拼团数
  47. * @param $activityId
  48. * @return int
  49. */
  50. public static function countActJoin($activityId){
  51. return self::where('group_buy_activity_id',$activityId)->where('status','<',3)
  52. ->count('id');
  53. }
  54. }