作者 何书鹏

多规格-把规格最小值作为商品价格

... ... @@ -115,6 +115,8 @@ class Goods extends Backend
if (!preg_match('/^[0-9]+(.[0-9]{1,8})?$/', $params['price'])) {
$this->error("请填写正确的价格");
}
}else{
$params['price'] = 0;
}
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
... ... @@ -129,6 +131,12 @@ class Goods extends Backend
}
$this->editSku($this->model, $sku, 'add');
// 多规格-把规格最小值作为商品价格
if($params['is_sku']){
// 把规格最小值作为商品价格
$skuPrice = \app\admin\model\shopro\goods\SkuPrice::all(['goods_id' => $this->model->id]);
$this->model->save(['price'=>min(array_column($skuPrice,'price'))]);
}
Db::commit();
... ... @@ -231,6 +239,14 @@ class Goods extends Backend
$this->error($row->getError());
} else {
$this->editSku($row, $sku, 'edit');
// 多规格-把规格最小值作为商品价格
if($row['is_sku']){
// 把规格最小值作为商品价格
$skuPrice = \app\admin\model\shopro\goods\SkuPrice::all(['goods_id' => $row->id]);
$row->save(['price'=>min(array_column($skuPrice,'price'))]);
}
Db::commit();
}
} catch (ValidateException $e) {
... ...
... ... @@ -753,13 +753,13 @@ width: 100%;
<div class="msg-tip" style="margin-left: 15px;">如果商品参与了拼团,秒杀,积分商城等活动,编辑规格可能导致活动规格不可用</div>
</div>
</el-form-item>
<el-form-item label="售卖价格:" prop="price" v-if="goodsDetail.is_sku==1">
<!--<el-form-item label="售卖价格:" prop="price" v-if="goodsDetail.is_sku==1">
<div class="display-flex">
<el-input type="text" v-model="goodsDetail.price" style="width:300px">
</el-input>
<div class="msg-tip">商品没有优惠的情况下售卖的价格</div>
</div>
</el-form-item>
</el-form-item>-->
<el-form-item label="售卖价格:" prop="price" v-if="goodsDetail.is_sku==0">
<div class="display-flex">
<el-input type="number" v-model="goodsDetail.price" style="width:300px">
... ...
... ... @@ -740,13 +740,13 @@
<div class="msg-tip" style="margin-left: 20px;">如果商品参与了拼团,秒杀,积分商城等活动,编辑规格可能导致活动规格不可用</div>
</div>
</el-form-item>
<el-form-item label="售卖价格:" prop="price" v-if="goodsDetail.is_sku==1">
<!--<el-form-item label="售卖价格:" prop="price" v-if="goodsDetail.is_sku==1">
<div class="display-flex">
<el-input type="text" v-model="goodsDetail.price" style="width:300px">
</el-input>
<div class="msg-tip">商品没有优惠的情况下售卖的价格</div>
</div>
</el-form-item>
</el-form-item>-->
<el-form-item label="售卖价格:" prop="price" v-if="goodsDetail.is_sku==0">
<div class="display-flex">
<el-input type="number" v-model="goodsDetail.price" style="width:300px">
... ...