_valid([ "goods.require" => trans("empty.require"), "spm.default" => "", "option.default" => "" ],$request->method()); if (!is_array($param)) return error($param); $data = $this->model->where("goods_id",$param['goods'])->with(['poi' => function ($query) { $query->field("poi_id,poi_name,poi_address,longitude,latitude,service_mobile,start_at,end_at,status"); },'skuSpecs'])->append(['otherImg'])->withAttr(['otherImg' => function ($qu,$resp) { $img = json_decode($resp['image_list'],true); return array_map(function ($v) { return $v['url']; }, $img); }])->findOrEmpty(); if ($data->isEmpty()) return errorTrans("empty.data"); if ($data['poi']['status'] <> 1) return error("该店铺已关闭,请联系管理员"); if (!empty($data['content'])) { $data['content'] = filterHtmlTags($data['content'],[ 'img' => [ 'remove' => ['width', 'height'], 'style' => ['width' => '100%'] ], 'p' => [ 'style' => ['margin' => '0'] ] ]); } return $this->encode("success",$data->toArray()); } catch (\Throwable $th) { return error($th->getMessage()); } } #[GetMapping("check")] public function checkGoodsUser (Request $request): Response { try { $param = $this->_valid([ "poi.default" => "" ],$request->method()); if (!is_array($param)) return error($param); $user = (new SaasUserOpen)->where(['openid' => $request->user['openid']])->findOrEmpty(); if ($user->isEmpty()) return error("数据错误"); $userState = 1; $isBuy = 1; if (empty($user['avatar'])) { $userState = 0; } if ($user['is_black'] == 1) { $isBuy = 0; } // 查询IP $userIp = $request->getRealIp(); $ipRegion = (new IpSearch)->getIpArea($userIp); if (isset($ipRegion[2]) && !empty($param['poi'])) { $areaBlack = (new SaasOrderArea)->where(['poi_id' => $param['poi'],'name' => $ipRegion[2]])->findOrEmpty(); if (!$areaBlack->isEmpty()) { $isBuy = 0; } } $msg = "当前门店无库存,请咨询客服"; return success("ok",['user' => $userState,'buy' => $isBuy,'msg' => $msg]); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } }