getMessage(), 500); } } /** * Notes:修改绿色蔬菜 * @param string $goods_name * @param int $goods_id * @return int * User: YCP * Date: 2022/11/4 */ public static function updateFarmGoods(array $params, int $admin_id) { LifeFarmGoods::affairBegin(); try { $where = []; $where['goods_id'] = $params['goods_id']; $info = LifeFarmGoods::where($where)->first(); if(empty($info) || $info === false) { throw new \Exception('信息不存在'); } $params['goods_update_time'] = time(); $result = LifeFarmGoods::where($where)->update($params); if ($result !== false){ $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '修改生态农场绿色蔬菜-编号: ' . $params['goods_id']; plog('life-farmgoods-update', '悦活-修改生态农场绿色蔬菜', $msg); LifeFarmGoods::affairCommit(); return true; } throw new \Exception('操作失败!'); }catch (\Exception $exception){ LifeFarmGoods::affairRollback(); throw new \Exception($exception->getMessage(), 500); } } /** * Notes:删除绿色蔬菜 * @param int $goods_id * @return int * User: YCP * Date: 2022/11/4 */ public static function delFarmGoods($goods_id,$admin_id) { LifeFarmGoods::affairBegin(); try { $where = []; $where['goods_id'] = $goods_id; $data['goods_is_del'] = 1; $result = LifeFarmGoods::where($where)->update($data); if (!empty($result)){ $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '删除生态农场绿色蔬菜-编号: ' . $goods_id; plog('life-farmgoods-delete', '悦活-删除生态农场绿色蔬菜', $msg); LifeFarmGoods::affairCommit(); return true; }else{ return false; } }catch (\Exception $exception){ LifeFarmGoods::affairRollback(); throw new \Exception($exception->getMessage(), 500); } } /** * Notes:查询绿色蔬菜 * @param int $goods_id * @return int * User: YCP * Date: 2022/11/4 */ public static function farmGoodsInfo($goods_id) { $where = []; $where['goods_id'] = $goods_id; $result = LifeFarmGoods::with(['Shop','Category','MedicalCarePostage'])->where($where)->first(); if(empty($result) || $result === false) { throw new \Exception('信息不存在'); } return $result; } /** * Notes:修改状态 * @param string $food_name * @param int $food_status * @return int * User: YCP * Date: 2022/11/7 */ public static function updateStatus($goods_id, $goods_status) { LifeFarmGoods::affairBegin(); try { $where = []; $where['goods_id'] = $goods_id; $data = []; $data['goods_status'] = $goods_status; $result = LifeFarmGoods::where($where)->update($data); if ($result !== false){ LifeFarmGoods::affairCommit(); return true; } throw new \Exception('操作失败!'); }catch (\Exception $exception){ LifeFarmGoods::affairRollback(); throw new \Exception($exception->getMessage(), 500); } } }