This commit is contained in:
mkm 2023-11-16 13:44:02 +08:00
parent 29360e5153
commit 22c4cb8518

View File

@ -313,13 +313,13 @@ class ProductRepository extends BaseRepository
$res = $this->dao->get($id);
$data['svip_price_type'] = $res['svip_price_type'];
$settleParams = $this->setAttrValue($data, $id, 0, 1, $merId);
// $settleParams['cate'] = $this->setMerCate($data['mer_cate_id'], $id, $merId);
// $settleParams['attr'] = $this->setAttr($data['attr'], $id);
$settleParams['cate'] = $this->setMerCate($data['mer_cate_id'], $id, $merId);
$settleParams['attr'] = $this->setAttr($data['attr'], $id);
$data['price'] = $settleParams['data']['price'];
unset($data['attrValue'], $data['attr'], $data['mer_cate_id']);
$ret = Spu::getInstance()->where('product_id', $id)->whereIn('product_type', [0, 98, 99])->find();
Db::transaction(function () use ($id, $data, $settleParams, $ret) {
$this->save($id, $settleParams, null, [], 0,false);
$this->save($id, $settleParams, null, [], 0);
app()->make(SpuRepository::class)->update($ret->spu_id, ['price' => $data['price']]);
Queue(SendSmsJob::class, ['tempId' => 'PRODUCT_INCREASE', 'id' => $id]);
});
@ -349,13 +349,11 @@ class ProductRepository extends BaseRepository
* @param $content
* @return int
*/
public function save($id, $settleParams, $content, $data = [], $productType = 0,$is_phone=true)
public function save($id, $settleParams, $content, $data = [], $productType = 0)
{
if($is_phone==true){
(app()->make(ProductAttrRepository::class))->clearAttr($id);
(app()->make(ProductAttrValueRepository::class))->clearAttr($id);
(app()->make(ProductCateRepository::class))->clearAttr($id);
}
if (isset($settleParams['cate'])) (app()->make(ProductCateRepository::class)->insert($settleParams['cate']));
if (isset($settleParams['attr'])) (app()->make(ProductAttrRepository::class))->insert($settleParams['attr']);
@ -456,7 +454,6 @@ class ProductRepository extends BaseRepository
$integral_rate = $data['integral_rate'];
if ($data['integral_rate'] < 0) $integral_rate = -1;
if ($data['integral_rate'] > 100) $integral_rate = 100;
}
$result = [
'store_name' => $data['store_name'],
@ -670,7 +667,8 @@ class ProductRepository extends BaseRepository
*/
public function getAdminOneProduct(int $id, ?int $activeId, $conType = 0)
{
$with = ['attr', 'attrValue', 'oldAttrValue', 'merCateId.category', 'storeCategory', 'brand', 'temp', 'seckillActive',
$with = [
'attr', 'attrValue', 'oldAttrValue', 'merCateId.category', 'storeCategory', 'brand', 'temp', 'seckillActive',
'content',
'merchant' => function ($query) {
$query->field('mer_id,mer_avatar,mer_name,is_trader');
@ -774,12 +772,10 @@ class ProductRepository extends BaseRepository
$content .= '<img src=' . $v . '></br>';
}
}
}
} else {
$content = $arr;
}
}
unset($data['content']);
$data['content'] = $content;
@ -1268,7 +1264,6 @@ class ProductRepository extends BaseRepository
// $img =$img. '<img src="'.$v.'"/>';
// }
$res['content']['content'] = ['image' => $image];
} elseif (is_object($content)) {
$image = $content->image ?? [];
// $img='<p>';
@ -1276,8 +1271,7 @@ class ProductRepository extends BaseRepository
// $img =$img. '<img src="'.$v.'"/>';
// }
$res['content']['content'] = ['image' => $image];
}
else{
} else {
if (is_Array($content)) {
$res['content']['content'] = ['image' => $content];
} else {
@ -1697,7 +1691,6 @@ class ProductRepository extends BaseRepository
app()->make(SpuRepository::class)->changeStatus($id, $product->product_type);
event('product.sell', ['product_id' => [$id]]);
$this->switchShow($id, $status, 'is_used', 0);
}
/**
@ -1726,7 +1719,6 @@ class ProductRepository extends BaseRepository
if ($data['status'] == 1) {
$this->switchShow($product['product_id'], 1, 'is_used', 0);
}
}
$this->dao->updates($id, $data);
Queue(ChangeSpuStatusJob::class, ['id' => $id, 'product_type' => $product_type]);
@ -2088,7 +2080,8 @@ class ProductRepository extends BaseRepository
$query->field('guarantee_id,guarantee_name,guarantee_info');
}
],
])->find();
]
)->find();
return $data ?? [];
}
@ -2220,8 +2213,7 @@ class ProductRepository extends BaseRepository
*/
public function getPreview(array $data)
{
switch($data['product_type'])
{
switch ($data['product_type']) {
case 0:
case 98:
case 99:
@ -2398,7 +2390,6 @@ class ProductRepository extends BaseRepository
$productId = $this->import($params['order_product_id'], request()->userInfo());
$product = $this->get($productId);
$attrValue = ProductAttrValue::where('mer_id', $merId)->where('product_id', $productId)->find();
}
} else {
//有商品有规格
@ -2548,5 +2539,4 @@ class ProductRepository extends BaseRepository
);
return compact('count', 'list');
}
}