$param['item_type'], 'item_name' => $param['item_name'], 'item_unit' => $param['item_unit'], 'item_memo' => $param['item_memo'], 'area' => $param['area'], 'area_name' => $param['area_name'], 'province' => $param['province'], 'province_name' => $param['province_name'], 'city' => $param['city'], 'city_name' => $param['city_name'], 'detail_address' => $param['detail_address'], 'purchase_user_id'=>$param['purchase_user_id'] ]; $model = new CfItem(); if (empty($param['id'])) { $data['create_id'] = $param['create_id']; $data['group_id'] = $param['group_id']; $id = $model->insertGetId($data); return Util::returnArrSu("", $id); } else { $model->save($data, ['id' => $param['id']]); return Util::returnArrSu("", $param['id']); } } catch (\Exception $e) { return Util::returnArrEr("更新记录失败:" . $e->getMessage()); } } /** * 获取列表 * @param $param * @return array */ public function getList($param) { try { $where = ["del_flag"=>0,"group_id"=>$param['group_id']]; if (!empty($param['item_name'])) { $where['item_name'] = ["like","%".$param['item_name']."%"]; } if (!empty($param['item_type'])) { $where["item_type"] = $param['item_type']; } if (!empty($param['area'])) { $where["area"] = $param['area']; } if (!empty($param['province'])) { $where["province"] = $param['province']; } if (!empty($param['city'])) { $where["city"] = $param['city']; } $offset = ($param['pageNum'] - 1) * $param['pageSize']; $model = new CfItem(); $total = $model->where($where)->count(); $list = $model->where($where) ->limit($offset, $param['pageSize']) ->order("id","DESC")->select(); $data = ["total" => $total, "list" => $list->toArray()]; return Util::returnArrSu("", $data); } catch (\Exception $e) { return Util::returnArrSu("", ["total" => 0, "list" => []]); } } /** * 删除 * @param $id * @return array */ public function del($id){ try { //设置收购单状态 $model = new CfItem(); $model->save(['del_flag' => 1], ['id' => $id]); return Util::returnArrSu(); } catch (\Exception $e) { return Util::returnArrEr("修改状态失败" . $e->getMessage()); } } }