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]);
});
}