PropertyCommissionLists.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\api\lists\property;
  3. use app\api\lists\BaseApiDataLists;
  4. use app\common\lists\ListsExtendInterface;
  5. use app\common\lists\ListsSearchInterface;
  6. use app\common\model\property\PropertyCommission;
  7. use app\common\model\property\PropertyHead;
  8. use app\common\model\property\PropertySurplusLog;
  9. use app\common\model\recharge\RechargeOrder;
  10. /**
  11. * 订单列表
  12. */
  13. class PropertyCommissionLists extends BaseApiDataLists implements ListsSearchInterface,ListsExtendInterface
  14. {
  15. public function setSearch(): array
  16. {
  17. return [
  18. '=' => ['id'],
  19. ];
  20. }
  21. public function queryWhere()
  22. {
  23. // 指定用户
  24. $propertyHeadId = PropertyHead::where('user_id',$this->userId)->value('id');
  25. $where[] = ['property_head_id', '=', $propertyHeadId];
  26. return $where;
  27. }
  28. public function lists(): array
  29. {
  30. $lists = PropertyCommission::with(['propertyHead','propertyUser','propertyWork'])->where($this->searchWhere)
  31. ->where($this->queryWhere())
  32. ->limit($this->limitOffset, $this->limitLength)
  33. ->field(['id','property_head_id','property_user_id','property_order_id','work_id','create_time','update_time','order_amount','commission_amount'])
  34. ->order('create_time desc')
  35. ->select()
  36. ->toArray();
  37. foreach ($lists as &$item){
  38. $item['orderGoods'] = (RechargeOrder::with(['orderGoods'])->where([
  39. ['work_id', '=', $item['work_id']],
  40. ['payment_type', 'IN', [0,1]]
  41. ])->find())['orderGoods'][0];
  42. $item['rechargeOrder'] = RechargeOrder::where([
  43. ['order_type', '=', 0],
  44. ['work_id', '=', $item['work_id']]
  45. ])->find();
  46. $item['work_title'] = $item['propertyWork']?$item['propertyWork']['title']:'';
  47. $item['work_create_time'] = $item['propertyWork']?$item['propertyWork']['create_time']:'';
  48. $item['worker_price'] = $item['propertyWork']?$item['propertyWork']['worker_price']:'';
  49. $item['work_amount'] = $item['propertyWork']?$item['propertyWork']['work_amount']:'';
  50. $item['work_total'] = $item['propertyWork']?$item['propertyWork']['work_total']:'';
  51. $item['service_fee'] = $item['propertyWork']?$item['propertyWork']['service_fee']:'';
  52. $item['work_sn'] = $item['propertyWork']?$item['propertyWork']['work_sn']:'';
  53. $item['goods_image'] = $item['orderGoods']?$item['orderGoods']['goods_image']:'';
  54. $item['sn'] = $item['rechargeOrder']?$item['rechargeOrder']['sn']:'';
  55. }
  56. return $lists;
  57. }
  58. /**
  59. * @notes 获取数量
  60. * @return int
  61. */
  62. public function count(): int
  63. {
  64. return PropertyCommission::where($this->searchWhere)->where($this->queryWhere())->count();
  65. }
  66. /**
  67. * @notes 返回扩展数据
  68. * @return array|int
  69. */
  70. public function extend(): array
  71. {
  72. return [];
  73. }
  74. }