PropertyCommissionLists.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. $item['rechargeOrder'] = RechargeOrder::where([
  42. ['order_type', '=', 0],
  43. ['user_id', '=', $this->userId],
  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. }