id; $code=urldecode($request->code); DB::beginTransaction(); $re=Select::where('code',$code)->first(); if ($re){ if ($re->is_true==1){ return $this->error(50024,'','当前货物是假货不能进行零售!'); } if ($re->user_id!=$id){ return $this->error(50024,'','当前货物绑定的代理信息不是你!'); } if ($re->is_lowest!=1){ return $this->error(50024,'','零售只能使用小码进行零售!'); } if ($re->is_sell!=0){ return $this->error(50024,'','该商品已经零售!'); } $re->is_sell=1; if (!$re->save()){ throw new \Exception('1'); } $res=Select::where('sort',$re->pid)->first(); $res->is_full=1; if (!$res->save()){ throw new \Exception('1'); } if ($res->level!=1){ $ress=Select::where('sort',$re->pid)->first(); $ress->is_full=1; if (!$ress->save()){ throw new \Exception('1'); } } $sell=new Sell(); $sell->select_id=$re->id; $sell->select_good_id=$re->good_select_id; $sell->user_id=$re->user_id; if (!$sell->save()){ throw new \Exception('1'); } } DB::commit(); return $this->success([]); }catch (\Exception $exception){ DB::rollBack(); Log::error('零售失败,原因是'.$exception); return $this->error(50021,'','操作失败,请重试!'); } } /****/ public function get_user(Request $request){ } }