소스 검색

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

sunxbiao 1 년 전
부모
커밋
d326b12cb7
1개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 10 0
      app/common/repositories/store/product/ProductRepository.php

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

@@ -162,6 +162,16 @@ class ProductRepository extends BaseRepository
162
     public function create(array $data)
162
     public function create(array $data)
163
     {
163
     {
164
         return Db::transaction(function () use ($data) {
164
         return Db::transaction(function () use ($data) {
165
+            if ($data['extension_type'] != 1) {
166
+                $base_commission = Db::name('system_config_value')->where('config_key', 'base_commission')->where('mer_id', $data['mer_id'])->value('value');
167
+                if ($base_commission < 5) {
168
+                    $base_commission = 5;
169
+                }
170
+                foreach ($data['attrValue'] as &$value) {
171
+                    $value['extension_one'] = $base_commission;
172
+                }
173
+            }
174
+
165
             $pension = bcsub($data['attrValue'][0]['price'], bcmul($data['attrValue'][0]['price'], $data['commission'], 2), 2);
175
             $pension = bcsub($data['attrValue'][0]['price'], bcmul($data['attrValue'][0]['price'], $data['commission'], 2), 2);
166
             if ($data['pension'] > $pension) {
176
             if ($data['pension'] > $pension) {
167
                 return ['code' => 201, 'msg' => '养老金金额和佣金金额总和不能超过商品单价'];
177
                 return ['code' => 201, 'msg' => '养老金金额和佣金金额总和不能超过商品单价'];