|
|
@ -139,20 +139,25 @@ class Store extends Controller |
|
|
|
PriceSet::where('store_id', $storeid)->where('type', $params['type']??0)->delete(); |
|
|
|
PriceSet::where('store_id', $storeid)->where('type', $params['type']??0)->delete(); |
|
|
|
$inDatas = []; |
|
|
|
$inDatas = []; |
|
|
|
foreach ($params['list'] as $value) { |
|
|
|
foreach ($params['list'] as $value) { |
|
|
|
foreach ($value['price_list'] as $price) { |
|
|
|
$categorys = explode(",", $value['category']); |
|
|
|
$temp = [ |
|
|
|
foreach ($categorys as $category) { |
|
|
|
'category' => $value['category'], |
|
|
|
foreach ($value['price_list'] as $price) { |
|
|
|
'store_id' => $storeid, |
|
|
|
$temp = [ |
|
|
|
'type' => $params['type'], |
|
|
|
'category' => $value['category'], |
|
|
|
'min' => $price['min'], |
|
|
|
'code' => $category, |
|
|
|
'max' => $price['max'], |
|
|
|
'store_id' => $storeid, |
|
|
|
'add_price_rate' => $price['add_price_rate'], |
|
|
|
'type' => $params['type'], |
|
|
|
'create_time' => time(), |
|
|
|
'min' => $price['min'], |
|
|
|
'update_time' => time(), |
|
|
|
'max' => $price['max'], |
|
|
|
]; |
|
|
|
'add_price_rate' => $price['add_price_rate'], |
|
|
|
$inDatas[] = $temp; |
|
|
|
'create_time' => time(), |
|
|
|
|
|
|
|
'update_time' => time(), |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
$inDatas[] = $temp; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// echo "<pre>"; |
|
|
|
// echo "<pre>"; |
|
|
|
// print_r($inDatas); |
|
|
|
// print_r($inDatas); |
|
|
@ -165,7 +170,7 @@ class Store extends Controller |
|
|
|
public function getStorePriceInfo(int $type): Json |
|
|
|
public function getStorePriceInfo(int $type): Json |
|
|
|
{ |
|
|
|
{ |
|
|
|
$storeid = request()->header()['storeid']; |
|
|
|
$storeid = request()->header()['storeid']; |
|
|
|
$list = PriceSet::where('store_id',$storeid)->where('type', $params['type'] ?? 0)->field('category,min,max,add_price_rate')->select()->toArray(); |
|
|
|
$list = PriceSet::where('store_id',$storeid)->where('type', $params['type'] ?? 0)->field('category,code,min,max,add_price_rate')->group("category, min")->select()->toArray(); |
|
|
|
$data = []; |
|
|
|
$data = []; |
|
|
|
$arr = []; |
|
|
|
$arr = []; |
|
|
|
foreach ($list as $value) { |
|
|
|
foreach ($list as $value) { |
|
|
@ -185,20 +190,12 @@ class Store extends Controller |
|
|
|
public function test(int $type): Json |
|
|
|
public function test(int $type): Json |
|
|
|
{ |
|
|
|
{ |
|
|
|
$storeid = request()->header()['storeid']; |
|
|
|
$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 = []; |
|
|
|
$categoryIds = [1001,1002]; |
|
|
|
$arr = []; |
|
|
|
$list = PriceSet::distributionPrice(90, 50, $categoryIds); |
|
|
|
foreach ($list as $value) { |
|
|
|
|
|
|
|
$arr[$value['category']][] = $value; |
|
|
|
|
|
|
|
} |
|
|
|
return $this->renderSuccess($list); |
|
|
|
foreach ($arr as $key => $item) { |
|
|
|
|
|
|
|
$data['list'][] = [ |
|
|
|
|
|
|
|
'category' => $key, |
|
|
|
|
|
|
|
'price_list' => $item, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$data['type'] = $type; |
|
|
|
|
|
|
|
return $this->renderSuccess($data); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|