lqmac 8 months ago
parent a6dc7ca7d8
commit 98cbc65ad8
  1. 3
      app/common/model/Goods.php
  2. 60
      app/store/controller/Store.php

@ -500,7 +500,8 @@ class Goods extends BaseModel
$filter[] = ['spec_type', '=', $params['spec_type']];
}
//是否店内
if (isset($param['is_in_store']) && $param['is_in_store'] !== '') {
//if (isset($param['is_in_store']) && $param['is_in_store'] !== '') {
if (isset($param['is_in_store']) && $param['is_in_store']) {
$filter[] = ['is_in_store', '=', $params['is_in_store']];
}

@ -16,6 +16,7 @@ use app\common\model\store\StoreSettle;
use think\response\Json;
use app\store\model\Store as StoreModel;
use app\common\model\Channel;
use app\common\model\PriceSet;
/**
* 商家中心控制器
@ -86,4 +87,63 @@ class Store extends Controller
//$platformList = config('app.platformList');
return $this->renderSuccess($platformList);
}
public function setStorePrice(): Json
{
$params = $this->request->param();
$storeid = $this->storeId;
// var_dump($params);
// exit();
//先删除
PriceSet::where('store_id', $storeid)->where('type', $params['type'] ?? 0)->delete();
$inDatas = [];
foreach ($params['list'] as $value) {
$categorys = explode(",", $value['category']);
foreach ($categorys as $category) {
foreach ($value['price_list'] as $price) {
$temp = [
'category' => $value['category'],
'code' => $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 = $this->storeId;
$list = PriceSet::where('store_id', $storeid)->where('type', $type)->field('category,code,min,max,add_price_rate')->group("category, min")->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);
}
}

Loading…
Cancel
Save