This commit is contained in:
shengchanzhe 2023-12-26 10:21:38 +08:00
parent 8b5a8b7caf
commit 2c80160ede

View File

@ -330,6 +330,19 @@ class ProductRepository extends BaseRepository
public function freeTrial(int $id, array $data, int $merId)
{
if (isset($data['mer_labels'])&& $data['mer_labels']!='') {
$value = $data['mer_labels'];
if (!empty($value)) {
if (!is_array($value)) {
$data['mer_labels'] = ',' . $value . ',';
} else {
$data['mer_labels'] = ',' . implode(',', $value) . ',';
}
}
$ret = Spu::getInstance()->where('product_id', $id)->whereIn('product_type', [0, 98, 99])->find();
app()->make(SpuRepository::class)->update($ret->spu_id, ['mer_labels' => $data['mer_labels']]);
return true;
}
if (!$data['spec_type']) {
$data['attr'] = [];
if (count($data['attrValue']) > 1) throw new ValidateException('单规格商品属性错误');
@ -344,15 +357,7 @@ class ProductRepository extends BaseRepository
$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);
$value = $data['mer_labels'];
if (!empty($value)) {
if (!is_array($value)) {
$data['mer_labels'] = ',' . $value . ',';
} else {
$data['mer_labels'] = ',' . implode(',', $value) . ',';
}
}
app()->make(SpuRepository::class)->update($ret->spu_id, ['price' => $data['price'],'mer_labels'=>$data['mer_labels']]);
app()->make(SpuRepository::class)->update($ret->spu_id, ['price' => $data['price']]);
Queue(SendSmsJob::class, ['tempId' => 'PRODUCT_INCREASE', 'id' => $id]);
});
}
@ -734,7 +739,7 @@ class ProductRepository extends BaseRepository
if ($data['product_type'] == 3) $make = app()->make(ProductAssistSkuRepository::class);
if ($data['product_type'] == 4) $make = app()->make(ProductGroupSkuRepository::class);
$spu_where = ['activity_id' => $activeId??0, 'product_type' => $data['product_type'], 'product_id' => $id];
$spu_where = ['activity_id' => $activeId ?? 0, 'product_type' => $data['product_type'], 'product_id' => $id];
$spu = $spu_make->getSearch($spu_where)->find();
$data['star'] = $spu['star'] ?? '';
$data['mer_labels'] = $spu['mer_labels'] ?? '';
@ -2607,7 +2612,7 @@ class ProductRepository extends BaseRepository
$data['type'] = 8;
break;
}
$store_product=Db::name('store_product')->where('product_id',$data['product_id'])->find();
$store_product = Db::name('store_product')->where('product_id', $data['product_id'])->find();
$datas = [
'product_id' => $data['product_id'],
'cate_id' => $store_product['cate_id'],
@ -2621,11 +2626,11 @@ class ProductRepository extends BaseRepository
'create_time' => date('Y-m-d H:i:s'),
'mer_labels' => ',' . $data['type'] . ',',
];
$res= Db::name('cloud_product')->where('product_id',$data['product_id'])->where('mer_id',$merchant['mer_id'])->find();
if($res){
$res = Db::name('cloud_product')->where('product_id', $data['product_id'])->where('mer_id', $merchant['mer_id'])->find();
if ($res) {
throw new ValidateException('该商品已设置过');
}
return Db::name('cloud_product')->insert($datas);
return Db::name('cloud_product')->insert($datas);
}
return false;
}