|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|