From 822ccb64188a233bf07c1565891dd89cd4b4ab48 Mon Sep 17 00:00:00 2001 From: Wayne <943146732@qq.com> Date: Wed, 28 Feb 2024 17:21:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BF=9D=E5=AD=98=20rema?= =?UTF-8?q?rk=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/model/store/Shop.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/store/model/store/Shop.php b/app/store/model/store/Shop.php index 1fdd1674..65965eb8 100644 --- a/app/store/model/store/Shop.php +++ b/app/store/model/store/Shop.php @@ -88,6 +88,7 @@ class Shop extends ShopModel if (!$this->validateForm($data)) { return false; } + $data['remark'] = json_encode($data['remark'], JSON_UNESCAPED_UNICODE); return $this->save($this->createData($data)); } @@ -101,6 +102,7 @@ class Shop extends ShopModel if (!$this->validateForm($data)) { return false; } + $data['remark'] = json_encode($data['remark'], JSON_UNESCAPED_UNICODE); return $this->save($this->createData($data)) !== false; } From 2f955a0c23a60763fac6c5475c88fe5350b86fc4 Mon Sep 17 00:00:00 2001 From: lqmac Date: Wed, 28 Feb 2024 17:23:44 +0800 Subject: [PATCH 2/2] 1 --- app/api/controller/Store.php | 97 +++++++++++++++++++++++++++++++++-- app/common/model/PriceSet.php | 31 +++++++++++ 2 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 app/common/model/PriceSet.php diff --git a/app/api/controller/Store.php b/app/api/controller/Store.php index 53df79e6..93d22a2e 100644 --- a/app/api/controller/Store.php +++ b/app/api/controller/Store.php @@ -22,7 +22,8 @@ use think\db\exception\ModelNotFoundException; use app\api\validate\store\Store as StoreValidte; use \app\common\model\Store as StoreInfoModel; use app\common\model\UploadFile; - +use app\common\model\PriceSet; +use think\Db; /** * 商城基础信息 * Class Store @@ -93,9 +94,16 @@ class Store extends Controller { $params = $this->request->param(); $storeid = request()->header()['storeid']; - $upData = [ - 'group_share_img_id'=>$params['group_share_img_id']??0 - ]; + $upData = []; + if (isset($params['group_share_img_id']) && $params['group_share_img_id']) { + $upData['group_share_img_id'] = $params['group_share_img_id']; + } + if (isset($params['min_profit']) && $params['min_profit']) { + $upData['min_profit'] = $params['min_profit']; + } + if (!$upData) { + return $this->renderSuccess('ok'); + } StoreInfoModel::where('store_id',$storeid)->update($upData); return $this->renderSuccess('ok'); } @@ -121,6 +129,87 @@ class Store extends Controller return $this->renderSuccess($list->toArray()); } + public function setStorePrice(): Json + { + $params = $this->request->param(); + $storeid = request()->header()['storeid']; + // var_dump($params); + // exit(); + //先删除 + PriceSet::where('store_id', $storeid)->where('type', $params['type']??0)->delete(); + $inDatas = []; + foreach ($params['list'] as $value) { + foreach ($value['price_list'] as $price) { + $temp = [ + 'category' => $value['category'], + 'store_id' => $storeid, + 'type' => $params['type'], + 'min' => $price['min'], + 'max' => $price['max'], + 'add_price_rate' => $price['add_price_rate'], + 'create_time' => time(), + 'update_time' => time(), + ]; + $inDatas[] = $temp; + } + + } + // echo "
";
+        // print_r($inDatas);
+        // exit();
+        $model = new PriceSet;
+        $model->addAll($inDatas);
+        return $this->renderSuccess('ok');
+    }
+    //加个设置回显
+    public function getStorePriceInfo(int $type): Json
+    {
+        $storeid = request()->header()['storeid'];
+        $list = PriceSet::where('store_id',$storeid)->where('type', $params['type'] ?? 0)->field('category,min,max,add_price_rate')->select()->toArray();
+        $data = [];
+        $arr = [];
+        foreach ($list as $value) {
+            $arr[$value['category']][] = $value;
+        }
+        foreach ($arr as $key => $item) {
+            $data['list'][] = [
+                'category' => $key,
+                'price_list' => $item,
+            ];
+        }
+        $data['type'] = $type;
+        return $this->renderSuccess($data);
+    }
+
+    //加个设置回显
+    public function test(int $type): Json
+    {
+        $storeid = request()->header()['storeid'];
+        $list = PriceSet::where('store_id',$storeid)->where('type', $params['type'] ?? 0)->field('category,min,max,add_price_rate')->select()->toArray();
+        $data = [];
+        $arr = [];
+        foreach ($list as $value) {
+            $arr[$value['category']][] = $value;
+        }
+        foreach ($arr as $key => $item) {
+            $data['list'][] = [
+                'category' => $key,
+                'price_list' => $item,
+            ];
+        }
+        $data['type'] = $type;
+        return $this->renderSuccess($data);
+    }
+
+
+
+
+
+
+
+
+
+
 
 
 }
\ No newline at end of file
diff --git a/app/common/model/PriceSet.php b/app/common/model/PriceSet.php
new file mode 100644
index 00000000..bf2766e4
--- /dev/null
+++ b/app/common/model/PriceSet.php
@@ -0,0 +1,31 @@
+
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\common\model;
+
+use cores\BaseModel;
+use think\model\relation\HasOne;
+use app\common\model\store\Shop;
+/**
+ * 活动栏目模型类
+ * Class User
+ * @package app\common\model
+ */
+class PriceSet extends BaseModel
+{
+    // 定义表名
+    protected $name = 'price_set';
+
+    // 定义主键
+    protected $pk = 'id';
+
+}