Explorar o código

修复添加商品默认分润比不生效问题

sunxbiao hai 1 ano
pai
achega
c1524dcd66

+ 9 - 0
app/common/repositories/store/product/ProductRepository.php

@@ -253,6 +253,15 @@ class ProductRepository extends BaseRepository
253 253
     public function update(int $id, array $data, $merId)
254 254
     {
255 255
         Db::transaction(function () use ($id, $data, $merId) {
256
+            if ($data['extension_type'] != 1) {
257
+                $base_commission = Db::name('system_config_value')->where('config_key', 'base_commission')->where('mer_id', $merId)->value('value');
258
+                if ($base_commission < 5) {
259
+                    $base_commission = 5;
260
+                }
261
+                foreach ($data['attrValue'] as &$value) {
262
+                    $value['extension_one'] = $base_commission;
263
+                }
264
+            }
256 265
             $param['attr'] = $data['attr'] ?? '';
257 266
             $param['attrValue'] = $data['attrValue'] ?? '';
258 267
             $param['cate'] = $data['mer_cate_id'] ?? '';