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