商品库
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user