service->setModel()->getList($request->all(),null,true,['type'],['type' => function($query,$resp){ if (empty($resp['product_type'])) return []; $productType = json_decode($resp['product_type'],true); $typeData = []; foreach ($this->goodsService->productType() as $key => $value) { if (in_array($value['key'],$productType)) { $typeData[] = $value['name']; } } return $typeData; }]); return successTrans(100010,pageFormat($data),200); } catch (\Throwable $th) { return error($th->getMessage()); } } /** * 同步POI门店 * @param Request $request * @return Response */ #[GetMapping('sync')] public function syncStore(Request $request): Response { try { Redis::send("sync-store",[ "appid" => sConf("wechat.appid"), "secret" => sConf("wechat.secret"), "account" => sConf("wechat.shop_id"), ]); return success("发起成功"); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } /** * 编辑代理信息 * @param Request $request * @return Response */ #[PostMapping("edit")] public function setListData(Request $request): Response { try { $param = $request->post(); $factory = $this->model->where("id",$param['id'])->findOrEmpty(); if ($factory->isEmpty()) return errorTrans("error.data"); $state = $this->model->setAutoData($param); if (!$state) return errorTrans("error.data"); return successTrans("success.data"); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } /** * 批量操作 * @param Request $request * @return Response */ #[PostMapping("batch")] public function setGoodsBatch(Request $request): Response { try { $param = $this->_valid([ "id.require" => "参数错误", "value.require" => "参数错误", "field.require" => "参数错误", "type.require" => "参数错误" ],"post"); if (!is_array($param)) return error($param); if ($param['type'] == "batch") { $state = $this->model->where("id","in",$param['id'])->save([$param['field'] => $param['value']]); } else { $state = $this->model->where("id",$param['id'])->save([$param['field'] => $param['value']]); } if (!$state) return errorTrans("error.data"); return successTrans("success.data"); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } #[GetMapping("cate")] public function getCategory(): Response { try { $data = $this->goodsService->productType(); return successTrans("success",compact('data')); } catch (\Throwable $throwable) { return error($throwable->getMessage()); } } }