params['type'])){ $where[] = ['verification_status','=',$this->params['type']]; } // 已售后成且订单已关闭的订单 无需再显示在待核销列表 if (($this->params['type'] ?? 0) == 0) { $where[] = [ 'order_status', 'in', [ OrderEnum::STATUS_WAIT_DELIVERY, OrderEnum::STATUS_WAIT_RECEIVE, ], ]; } return $where; } /** * @notes 实现数据列表 * @return array * @author 令狐冲 * @date 2021/7/6 00:33 */ public function lists(): array { $lists = Order::withSearch(['order_type'], [ 'order_type' => $this->params['type'], ]) ->with(['order_goods' => function ($query) { $query->field('id,goods_id,order_id,goods_snap,goods_name,goods_price,goods_num,is_comment,original_price') ->append(['goods_image', 'spec_value_str']) ->hidden(['goods_snap']); }]) ->append(['consignee','mobile']) ->hidden(['address']) ->where($this->searchwhere()) ->field(['id', 'sn', 'user_id','order_type', 'order_status', 'total_num', 'order_amount', 'delivery_type', 'pay_status','address','create_time','verification_status']) ->order(['id' => 'desc']) ->limit($this->limitOffset, $this->limitLength) ->select()->toArray(); foreach ($lists as &$list){ foreach ($list['order_goods'] as &$orderGoods){ //售后状态 $orderGoods['after_sale_status_desc'] = '无售后'; $after_sale = AfterSale::where(['order_goods_id' => $orderGoods['id'], 'order_id' => $orderGoods['order_id']])->findOrEmpty(); if (!$after_sale->isEmpty()) { $orderGoods['after_sale_status_desc'] = AfterSaleEnum::getStatusDesc($after_sale->status); } } } return $lists; } /** * @notes 实现数据列表记录数 * @return int * @author 令狐冲 * @date 2021/7/6 00:34 */ public function count(): int { return (new Order()) ->where($this->searchwhere()) ->count(); } }