PropertyCommissionLists.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. ['user_id', '=', $this->userId],
  45. ['work_id', '=', $item['work_id']]
  46. ])->find();
  47. $item['work_title'] = $item['propertyWork']?$item['propertyWork']['title']:'';
  48. $item['work_create_time'] = $item['propertyWork']?$item['propertyWork']['create_time']:'';
  49. $item['worker_price'] = $item['propertyWork']?$item['propertyWork']['worker_price']:'';
  50. $item['work_amount'] = $item['propertyWork']?$item['propertyWork']['work_amount']:'';
  51. $item['work_total'] = $item['propertyWork']?$item['propertyWork']['work_total']:'';
  52. $item['service_fee'] = $item['propertyWork']?$item['propertyWork']['service_fee']:'';
  53. $item['work_sn'] = $item['propertyWork']?$item['propertyWork']['work_sn']:'';
  54. $item['goods_image'] = $item['orderGoods']?$item['orderGoods']['goods_image']:'';
  55. $item['sn'] = $item['rechargeOrder']?$item['rechargeOrder']['sn']:'';
  56. }
  57. return $lists;
  58. }
  59. /**
  60. * @notes 获取数量
  61. * @return int
  62. */
  63. public function count(): int
  64. {
  65. return PropertyCommission::where($this->searchWhere)->where($this->queryWhere())->count();
  66. }
  67. /**
  68. * @notes 返回扩展数据
  69. * @return array|int
  70. */
  71. public function extend(): array
  72. {
  73. return [];
  74. }
  75. }