From 21cd070e92ef5432e7e54788586d26083488f713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=96=E7=95=8C?= <642747453@qq.com> Date: Mon, 24 Oct 2022 00:23:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20#10000=20=E5=BA=97=E9=93=BA=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=88=90=E6=9C=AC=E5=80=8D=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Shop/ShopsController.php | 11 +++++ .../2022_08_02_022448_create_shops_table.php | 1 + resources/frontend/src/api/shop.js | 44 ++++++++++------- resources/frontend/src/views/store/store.vue | 49 ++++++++++++++++--- 4 files changed, 80 insertions(+), 25 deletions(-) diff --git a/app/Http/Controllers/Shop/ShopsController.php b/app/Http/Controllers/Shop/ShopsController.php index ade2a69..34678f6 100644 --- a/app/Http/Controllers/Shop/ShopsController.php +++ b/app/Http/Controllers/Shop/ShopsController.php @@ -40,6 +40,7 @@ class ShopsController extends Controller $validator = Validator::make($request->all(), [ 'name' => 'required|string|max:191|unique:shops,name', 'plat_id' => 'required|integer', + 'ratio' => 'required|numeric', ]); if ($validator->fails()) { $this->setValidatorFailResponse($validator->getMessageBag()->getMessages()); @@ -49,6 +50,7 @@ class ShopsController extends Controller $shop = new Shop(); $shop->name = $request->name; $shop->plat_id = $request->plat_id; + $shop->ratio = $request->ratio; if (0 == $request->plat_id) { $shop->status = 2; } @@ -57,6 +59,15 @@ class ShopsController extends Controller return response($this->res, $this->res['httpCode']); } + public function update(Request $request, $id) + { + $shop = Shop::query()->find($id); + $shop->ratio = $request->ratio; + $shop->save(); + + return response($this->res, $this->res['httpCode']); + } + public function authBind(Request $request) { [$shopId, $platId] = explode('_', $request->get('state')); diff --git a/database/migrations/2022_08_02_022448_create_shops_table.php b/database/migrations/2022_08_02_022448_create_shops_table.php index e56de65..419e45c 100644 --- a/database/migrations/2022_08_02_022448_create_shops_table.php +++ b/database/migrations/2022_08_02_022448_create_shops_table.php @@ -29,6 +29,7 @@ class CreateShopsTable extends Migration $table->text('scope')->nullable()->comment('接口列表'); $table->text('pop_auth_token_create_response')->nullable()->comment('授权认证信息'); $table->unsignedTinyInteger('status')->index()->default(0)->comment('状态'); + $table->decimal('ratio')->default(1)->comment('成本倍率'); $table->softDeletes(); $table->timestamps(); //索引 diff --git a/resources/frontend/src/api/shop.js b/resources/frontend/src/api/shop.js index c26c067..1712ef7 100644 --- a/resources/frontend/src/api/shop.js +++ b/resources/frontend/src/api/shop.js @@ -4,32 +4,40 @@ import http from "@/util/http.js"; // 店铺平台 export function shopListId() { - return http({ - url: "/api/shop_platforms", - method: "get", - }); + return http({ + url: "/api/shop_platforms", + method: "get", + }); } // 店铺新增 export function shopAdd(data) { - return http({ - url: "/api/shops", - method: "post", - data, - }); + return http({ + url: "/api/shops", + method: "post", + data, + }); } // 店铺列表 export function storeList(params) { - return http({ - url: "/api/shops", - method: "get", - params, - }); + return http({ + url: "/api/shops", + method: "get", + params, + }); } // 下载商品 export function downloadGoods(id) { - return http({ - url: `/api/download/${id}/goods`, - method: "get", - }); + return http({ + url: `/api/download/${id}/goods`, + method: "get", + }); +} + +export function updateStore(id, params) { + return http({ + url: `/api/shops/${id}`, + method: "patch", + params, + }); } diff --git a/resources/frontend/src/views/store/store.vue b/resources/frontend/src/views/store/store.vue index 19451e2..77c92a1 100644 --- a/resources/frontend/src/views/store/store.vue +++ b/resources/frontend/src/views/store/store.vue @@ -5,10 +5,16 @@