|
|
|
@ -136,6 +136,38 @@ class Goods extends Controller |
|
|
|
|
// exit(); |
|
|
|
|
// 更新记录 |
|
|
|
|
if ($model->edit($this->postForm(), $model)) { |
|
|
|
|
//更新来源数据为当前数据的商品 |
|
|
|
|
$goods_sku = GoodsModel::where('goods_id', $goodsId)->where('store_id', 0)->find(); |
|
|
|
|
|
|
|
|
|
$list = GoodsModel::where('origin_goods_id', $goodsId)->field('goods_id')->select(); |
|
|
|
|
if (!$list) { |
|
|
|
|
return $this->renderSuccess('更新成功'); |
|
|
|
|
} |
|
|
|
|
$goods_data = [ |
|
|
|
|
'goods_name' => $goods_sku->name, |
|
|
|
|
'content' => $goods_sku->content, |
|
|
|
|
'selling_point' => $goods_sku->selling_point, |
|
|
|
|
'goods_price_min' => $goods_sku->goods_price_min, |
|
|
|
|
'goods_price_max' => $goods_sku->goods_price_max, |
|
|
|
|
'line_price_min' => $goods_sku->line_price_min, |
|
|
|
|
'line_price_max' => $goods_sku->line_price_max, |
|
|
|
|
'cost_price_min' => $goods_sku->cost_price_min, |
|
|
|
|
'profit_rate' => $goods_sku->profit_rate, |
|
|
|
|
'profit' => $goods_sku->profit, |
|
|
|
|
'goods_source' => $goods_sku->goods_source, |
|
|
|
|
'is_check' => $goods_sku->is_check, |
|
|
|
|
'delivery_time' => $goods_sku->delivery_time, |
|
|
|
|
'update_time' => time(), |
|
|
|
|
]; |
|
|
|
|
GoodsModel::where('origin_goods_id', $goodsId)->update($goods_data); |
|
|
|
|
$goods_sku_data = [ |
|
|
|
|
'goods_price' => $goods_sku->goods_price_min, |
|
|
|
|
'cost_price' => $goods_sku->cost_price_min, |
|
|
|
|
'update_time' => time(), |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GoodsSku::whereIn('goods_id', array_column($list->toArray(), "goods_id"))->update($goods_sku_data); |
|
|
|
|
return $this->renderSuccess('更新成功'); |
|
|
|
|
} |
|
|
|
|
return $this->renderError($model->getError() ?: '更新失败'); |
|
|
|
|