PropertyCommissionLists.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\api\lists\property;
  3. use app\api\lists\BaseApiDataLists;
  4. use app\common\lists\ListsSearchInterface;
  5. use app\common\model\property\PropertyCommission;
  6. use app\common\model\property\PropertyHead;
  7. use app\common\model\property\PropertySurplusLog;
  8. use app\common\model\recharge\RechargeOrder;
  9. /**
  10. * 订单列表
  11. */
  12. class PropertyCommissionLists extends BaseApiDataLists implements ListsSearchInterface
  13. {
  14. public function setSearch(): array
  15. {
  16. return [
  17. '=' => ['id'],
  18. ];
  19. }
  20. public function queryWhere()
  21. {
  22. // 指定用户
  23. $propertyHeadId = PropertyHead::where('user_id',$this->userId)->value('id');
  24. $where[] = ['property_head_id', '=', $propertyHeadId];
  25. return $where;
  26. }
  27. public function lists(): array
  28. {
  29. $lists = PropertyCommission::with(['propertyHead','propertyUser','propertyWork'])->where($this->searchWhere)
  30. ->where($this->queryWhere())
  31. ->limit($this->limitOffset, $this->limitLength)
  32. ->field(['id','property_head_id','property_user_id','property_order_id','work_id','create_time','update_time','order_amount','commission_amount'])
  33. ->order('create_time desc')
  34. ->select()
  35. ->toArray();
  36. foreach ($lists as &$item){
  37. $item['orderGoods'] = (RechargeOrder::with(['orderGoods'])->where([
  38. ['work_id', '=', $item['work_id']],
  39. ['payment_type', 'IN', [0,1]]
  40. ])->find())['orderGoods'][0];
  41. }
  42. return $lists;
  43. }
  44. /**
  45. * @notes 获取数量
  46. * @return int
  47. */
  48. public function count(): int
  49. {
  50. return PropertyCommission::where($this->searchWhere)->where($this->queryWhere())->count();
  51. }
  52. }