|
|
|
@ -13,6 +13,8 @@ |
|
|
|
|
|
|
|
|
|
namespace app\common\repositories\store\product; |
|
|
|
|
|
|
|
|
|
use app\common\model\store\product\Product; |
|
|
|
|
use app\common\model\store\product\Spu; |
|
|
|
|
use app\common\model\store\product\ProductLabel; |
|
|
|
|
use app\common\model\user\User; |
|
|
|
|
use app\common\repositories\community\CommunityRepository; |
|
|
|
@ -60,7 +62,7 @@ class ProductRepository extends BaseRepository |
|
|
|
|
|
|
|
|
|
protected $dao; |
|
|
|
|
const CREATE_PARAMS = [ |
|
|
|
|
"image", "slider_image", "store_name", "store_info", "keyword", "bar_code", "guarantee_template_id", "cate_id", "mer_cate_id", "unit_name", "sort" , "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free','param_temp_id','extend', |
|
|
|
|
"image", "slider_image", "store_name", "store_info", "keyword", "bar_code",'is_pre', "guarantee_template_id", "cate_id", "mer_cate_id", "unit_name", "sort" , "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free','param_temp_id','extend', |
|
|
|
|
["brand_id",0], |
|
|
|
|
['once_max_count',0], |
|
|
|
|
['once_min_count',0], |
|
|
|
@ -258,6 +260,7 @@ class ProductRepository extends BaseRepository |
|
|
|
|
$data['attr'] = []; |
|
|
|
|
if (count($data['attrValue']) > 1) throw new ValidateException('单规格商品属性错误'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
event('product.update.before', compact('id','data','merId','productType','conType')); |
|
|
|
|
$spuData = $product = $this->setProduct($data); |
|
|
|
|
$settleParams = $this->setAttrValue($data, $id, $productType, 1); |
|
|
|
@ -270,7 +273,7 @@ class ProductRepository extends BaseRepository |
|
|
|
|
$spuData['price'] = $settleParams['data']['price']; |
|
|
|
|
$spuData['mer_id'] = $merId; |
|
|
|
|
$spuData['mer_labels'] = $data['mer_labels']; |
|
|
|
|
|
|
|
|
|
$spuData['is_pre'] = $data['is_pre']; |
|
|
|
|
Db::transaction(function () use ($id, $data, $productType, $settleParams,$content,$product,$spuData,$merId) { |
|
|
|
|
$this->save($id, $settleParams, $content, $product, $productType); |
|
|
|
|
if ($productType == 1) { //秒杀商品 |
|
|
|
@ -593,6 +596,7 @@ class ProductRepository extends BaseRepository |
|
|
|
|
"extension_two" => $extension_status ? ($value['extension_two'] ?? 0) : 0, |
|
|
|
|
"product_id" => $productId, |
|
|
|
|
"type" => 0, |
|
|
|
|
|
|
|
|
|
"sku" => $sku, |
|
|
|
|
"unique" => $unique, |
|
|
|
|
'sales' => $isUpdate ? ($oldSku[$sku]['sales'] ?? 0) : 0, |
|
|
|
@ -734,6 +738,11 @@ class ProductRepository extends BaseRepository |
|
|
|
|
if ($conType) $content = json_decode($content); |
|
|
|
|
unset($data['content']); |
|
|
|
|
$data['content'] = $content; |
|
|
|
|
|
|
|
|
|
$info = Spu::getDB() |
|
|
|
|
->where('product_id', $id)->find()->toArray(); |
|
|
|
|
|
|
|
|
|
$data['mer_labels'] = (int)$info['mer_labels'][0]; |
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|