| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace app\api\lists\property;
- use app\api\lists\BaseApiDataLists;
- use app\common\lists\ListsExtendInterface;
- use app\common\lists\ListsSearchInterface;
- use app\common\model\property\PropertyCommission;
- use app\common\model\property\PropertyHead;
- use app\common\model\property\PropertySurplusLog;
- use app\common\model\recharge\RechargeOrder;
- /**
- * 订单列表
- */
- class PropertyCommissionLists extends BaseApiDataLists implements ListsSearchInterface,ListsExtendInterface
- {
- public function setSearch(): array
- {
- return [
- '=' => ['id'],
- ];
- }
- public function queryWhere()
- {
- // 指定用户
- $propertyHeadId = PropertyHead::where('user_id',$this->userId)->value('id');
- $where[] = ['property_head_id', '=', $propertyHeadId];
- return $where;
- }
- public function lists(): array
- {
- $lists = PropertyCommission::with(['propertyHead','propertyUser','propertyWork'])->where($this->searchWhere)
- ->where($this->queryWhere())
- ->limit($this->limitOffset, $this->limitLength)
- ->field(['id','property_head_id','property_user_id','property_order_id','work_id','create_time','update_time','order_amount','commission_amount'])
- ->order('create_time desc')
- ->select()
- ->toArray();
- foreach ($lists as &$item){
- $item['orderGoods'] = (RechargeOrder::with(['orderGoods'])->where([
- ['work_id', '=', $item['work_id']],
- ['payment_type', 'IN', [0,1]]
- ])->find())['orderGoods'][0];
- $item['rechargeOrder'] = RechargeOrder::where([
- ['order_type', '=', 0],
- ['user_id', '=', $this->userId],
- ['work_id', '=', $item['work_id']]
- ])->find();
- $item['work_title'] = $item['propertyWork']?$item['propertyWork']['title']:'';
- $item['work_create_time'] = $item['propertyWork']?$item['propertyWork']['create_time']:'';
- $item['worker_price'] = $item['propertyWork']?$item['propertyWork']['worker_price']:'';
- $item['work_amount'] = $item['propertyWork']?$item['propertyWork']['work_amount']:'';
- $item['work_total'] = $item['propertyWork']?$item['propertyWork']['work_total']:'';
- $item['service_fee'] = $item['propertyWork']?$item['propertyWork']['service_fee']:'';
- $item['work_sn'] = $item['propertyWork']?$item['propertyWork']['work_sn']:'';
- $item['goods_image'] = $item['orderGoods']?$item['orderGoods']['goods_image']:'';
- $item['sn'] = $item['rechargeOrder']?$item['rechargeOrder']['sn']:'';
- }
- return $lists;
- }
- /**
- * @notes 获取数量
- * @return int
- */
- public function count(): int
- {
- return PropertyCommission::where($this->searchWhere)->where($this->queryWhere())->count();
- }
- /**
- * @notes 返回扩展数据
- * @return array|int
- */
- public function extend(): array
- {
- return [];
- }
- }
|