$id])->findOrEmpty(); if($goods->isEmpty()){ return true; } $goods->status = $goods->status ? 0 : 1; $goods->save(); } /** * @notes 服务详情 * @param $id * @return array * @author cjhao * @date 2024/10/29 13:10 */ public function detail($id) { $result = Goods::where('id',$id) ->withoutField('order_num,update_time,delete_time') ->append(['category_desc','goods_image']) ->findOrEmpty() ->toArray(); $goods_image = []; foreach ($result['goods_image'] as &$image) { $goods_image[] = $image['uri']; } $result['goods_image'] = $goods_image; $result['city_id'] = GoodsCityIndex::where(['goods_id'=>$id])->column('city_id'); $result['skill_id'] = GoodsSkillIndex::where(['goods_id'=>$id])->column('skill_id'); // $result['category_name'] = GoodsCategory::where(['id'=>$result['category_id']])->column('name'); $result['shop_name'] = Shop::where(['id'=>$result['shop_id']])->value('name'); return $result; } /** * @notes 审核 * @param $params * @return bool * @author cjhao * @date 2024/10/29 13:29 */ public function audit($params) { try { $detail = Goods::where(['id'=>$params['id']])->findOrEmpty(); if($detail->isEmpty()){ throw new Exception('服务不存在'); } if(0 != $detail->audit_status){ throw new Exception('审核状态已改变'); } $status = GoodsEnum::AUDIT_STATUS_PASS; if(0 == $params['audit_status']){ $status = GoodsEnum::AUDIT_STATUS_REFUSE; $detail->status = GoodsEnum::UNSHELVE; } $detail->audit_status = $status; $detail->audit_remark = $params['audit_remark'] ?? ''; $detail->save(); return true; }catch (\Exception $e){ self::$error = $e->getMessage(); return false; } } }