Merge pull request !165 from 赵世界/develop
This commit is contained in:
赵世界 2023-04-25 10:27:44 +00:00 committed by Gitee
commit d06d6a1ee8
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 4 additions and 1 deletions

View File

@ -90,6 +90,7 @@ class GoodsCombinationController extends Controller
$stock = $num; $stock = $num;
} }
} }
$status = $stock ? (5 < $stock ? 1 : 2) : 0;
if ($id = $request->input('id')) { if ($id = $request->input('id')) {
$sku = GoodsSku::query()->findOrFail($id); $sku = GoodsSku::query()->findOrFail($id);
} else { } else {
@ -97,6 +98,7 @@ class GoodsCombinationController extends Controller
$sku->goods_id = 0; $sku->goods_id = 0;
$sku->is_combination = 1; $sku->is_combination = 1;
} }
$sku->status = $status;
$sku->title = $request->input('title'); $sku->title = $request->input('title');
$sku->sku_code = $request->input('external_sku_id'); $sku->sku_code = $request->input('external_sku_id');
$sku->external_sku_id = $request->input('external_sku_id'); $sku->external_sku_id = $request->input('external_sku_id');

View File

@ -66,9 +66,10 @@ class CombinationGoodsImport implements ToArray, SkipsEmptyRows, WithStartRow
$stock = $num; $stock = $num;
} }
} }
$status = $stock ? (5 < $stock ? 1 : 2) : 0;
$sku = GoodsSku::query()->updateOrCreate( $sku = GoodsSku::query()->updateOrCreate(
['external_sku_id' => $info['external_sku_id'], 'is_combination' => 1], ['external_sku_id' => $info['external_sku_id'], 'is_combination' => 1],
['title' => $info['title'], 'goods_id' => 0, 'sku_code' => $info['external_sku_id'], 'stock' => $stock] ['title' => $info['title'], 'goods_id' => 0, 'sku_code' => $info['external_sku_id'], 'stock' => $stock, 'status' => $status]
); );
CombinationGood::query() CombinationGood::query()
->where('goods_sku_id', $sku->id) ->where('goods_sku_id', $sku->id)