['is_adopt', 'is_storage', 'order_id'], 'between_time'=>'create_time' ]; } /** * @notes 获取采购供应链商户报价列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @author likeadmin * @date 2024/04/27 11:26 */ public function lists(): array { $where = []; $is_mer = $this->request->get('is_mer', 0); $id = $this->request->get('id', 0); $type = $this->request->get('type', 'all'); if ($type == 1) { $where[] = ['is_adopt', '=', 0]; } elseif ($type == 2) { $where[] = ['is_adopt', '=', 1]; } if ($id) { $where[] = ['order_id', '=', $id]; } if ($this->request->supplierId > 0) { $where[] = ['supplier_id', '=', $this->request->supplierId]; } $this->where = $where; if ($this->request->__get('storage_list') == 1) { $list = OpurchaseGoodsOffer::where($this->searchWhere) ->where($where) ->limit($this->limitOffset, $this->limitLength) ->order('update_time', 'desc') ->select()->each(function ($item) { $find = Goods::where('id', $item['goods_id'])->with('unitName')->find(); if ($find) { $item['goods_name'] = $find['name']; $item['unit_name'] = $find['unit_name']; } $item['supplier_name'] = Supplier::where('id', $item['supplier_id'])->value('mer_name'); })->toArray(); } else { $list = OpurchaseGoodsOffer::where($this->searchWhere) ->where($where) ->limit($this->limitOffset, $this->limitLength) ->orderRaw("goods_id, CASE WHEN price = 0 THEN 999999999 ELSE price END ASC") ->select()->each(function ($item) { $find = Goods::where('id', $item['goods_id'])->with('unitName')->find(); if ($find) { $item['goods_name'] = $find['name']; $item['unit_name'] = $find['unit_name']; } $item['supplier_name'] = Supplier::where('id', $item['supplier_id'])->value('mer_name'); })->toArray(); } return $list; } /** * @notes 获取采购供应链商户报价数量 * @return int * @author likeadmin * @date 2024/04/27 11:26 */ public function count(): int { return OpurchaseGoodsOffer::where($this->searchWhere)->where($this->where)->count(); } }