|
|
|
@ -165,16 +165,23 @@ class StoreProduct extends BaseController |
|
|
|
|
public function update($id, validate $validate) |
|
|
|
|
{ |
|
|
|
|
$data = $this->checkParams($validate); |
|
|
|
|
$this->repository->adminUpdate($id, $data); |
|
|
|
|
|
|
|
|
|
$productAttrRepository = \app(ProductAttrValueRepository::class); |
|
|
|
|
$attrValue = Request::post('attrValue'); |
|
|
|
|
if($attrValue){ |
|
|
|
|
foreach ($attrValue as $item){ |
|
|
|
|
if($item['price'] < $item['cost']) |
|
|
|
|
return app('json')->fail("成本不能高于价格"); |
|
|
|
|
$productAttrRepository->update($item['value_id'], array('price' => $item['price'],'cost' => $item['cost'])); |
|
|
|
|
} |
|
|
|
|
$data['price'] = min(array_column($attrValue, 'price')); |
|
|
|
|
$data['cost'] = max(array_column($attrValue, 'cost')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->repository->adminUpdate($id, $data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return app('json')->success('编辑成功'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|