getMessage(), 500); } } /** * Notes:修改项目 * @param string $goods_name * @param int $goods_id * @return int * User: YCP * Date: 2022/10/31 */ public static function updateGoods(array $params, int $admin_id) { HomeGoods::affairBegin(); try { $where = []; $where['goods_id'] = $params['goods_id']; $info = HomeGoods::where($where)->first(); if(empty($info) || $info === false) { throw new \Exception('项目信息不存在'); } $params['goods_update_time'] = time(); $result = HomeGoods::where($where)->update($params); if ($result !== false){ $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '修改居家项目-编号: ' . $params['goods_id']; plog('life-homegoods-update', '居家-修改项目', $msg); HomeGoods::affairCommit(); return true; } throw new \Exception('操作失败!'); }catch (\Exception $exception){ HomeGoods::affairRollback(); throw new \Exception($exception->getMessage(), 500); } } /** * Notes:删除项目 * @param int $goods_id * @return int * User: YCP * Date: 2022/10/31 */ public static function delGoods($goods_id,$admin_id) { HomeGoods::affairBegin(); try { $where = []; $where['goods_id'] = $goods_id; $data['goods_is_del'] = 1; $result = HomeGoods::where($where)->update($data); if (!empty($result)){ $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '删除项目-编号: ' . $goods_id; plog('life-homegoods-delete', '居家-删除项目', $msg); HomeGoods::affairCommit(); return true; }else{ return false; } }catch (\Exception $exception){ HomeGoods::affairRollback(); throw new \Exception($exception->getMessage(), 500); } } /** * Notes:查询项目 * @param int $goods_id * @return int * User: YCP * Date: 2022/10/31 */ public static function goodsInfo($goods_id) { $where = []; $where['goods_id'] = $goods_id; $result = HomeGoods::where($where)->first(); if(empty($result) || $result === false) { throw new \Exception('项目信息不存在'); } return $result; } }