Merge branch 'main' of git.njrzwl.cn:wangmingchuan/yanzong into main

wysf
ztt 9 months ago
commit a09683a219
  1. 97
      app/api/controller/Store.php
  2. 31
      app/common/model/PriceSet.php
  3. 2
      app/store/model/store/Shop.php

@ -22,7 +22,8 @@ use think\db\exception\ModelNotFoundException;
use app\api\validate\store\Store as StoreValidte; use app\api\validate\store\Store as StoreValidte;
use \app\common\model\Store as StoreInfoModel; use \app\common\model\Store as StoreInfoModel;
use app\common\model\UploadFile; use app\common\model\UploadFile;
use app\common\model\PriceSet;
use think\Db;
/** /**
* 商城基础信息 * 商城基础信息
* Class Store * Class Store
@ -93,9 +94,16 @@ class Store extends Controller
{ {
$params = $this->request->param(); $params = $this->request->param();
$storeid = request()->header()['storeid']; $storeid = request()->header()['storeid'];
$upData = [ $upData = [];
'group_share_img_id'=>$params['group_share_img_id']??0 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); StoreInfoModel::where('store_id',$storeid)->update($upData);
return $this->renderSuccess('ok'); return $this->renderSuccess('ok');
} }
@ -121,6 +129,87 @@ class Store extends Controller
return $this->renderSuccess($list->toArray()); 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 "<pre>";
// 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);
}
} }

@ -0,0 +1,31 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
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';
}

@ -88,6 +88,7 @@ class Shop extends ShopModel
if (!$this->validateForm($data)) { if (!$this->validateForm($data)) {
return false; return false;
} }
$data['remark'] = json_encode($data['remark'], JSON_UNESCAPED_UNICODE);
return $this->save($this->createData($data)); return $this->save($this->createData($data));
} }
@ -101,6 +102,7 @@ class Shop extends ShopModel
if (!$this->validateForm($data)) { if (!$this->validateForm($data)) {
return false; return false;
} }
$data['remark'] = json_encode($data['remark'], JSON_UNESCAPED_UNICODE);
return $this->save($this->createData($data)) !== false; return $this->save($this->createData($data)) !== false;
} }

Loading…
Cancel
Save