商品库

This commit is contained in:
2025-12-17 10:40:58 +08:00
parent a02eddb0d0
commit 51b11b3437
13 changed files with 523 additions and 8 deletions
+10
View File
@@ -2,7 +2,9 @@
namespace app\common\service;
use app\common\model\PostCategory;
use app\common\model\PostMedia;
use app\common\model\Sku;
use app\common\model\User;
use app\common\validate\PostValidate;
use app\common\traits\crud\CrudServiceTrait;
@@ -115,6 +117,14 @@ class PostService
redis::set('PostMedia_'.$data['user_id'],$media,30);
unset($data['media']);
$category = PostCategory::where('id',$data['category_id'])->first();
foreach ($data['model'] as $key => $model) {
$code = (new SkuService)->generateUniqueCode();
Sku::firstOrCreate(['model' => $model], ['category_id' => $data['category_id'],
'product_name' => $category['name'],'code' => $code]);
}
$data['model'] = implode(',',$data['model']);
return $data;
}