ソースを参照

Merge branch 'dev'

xupuyuan 4 ヶ月 前
コミット
4c2b0f9751
共有2 個のファイルを変更した11 個の追加2 個の削除を含む
  1. 1 1
      app/common/dao/store/shipping/ShippingTemplateDao.php
  2. 10 1
      app/common/repositories/store/product/ProductRepository.php

+ 1 - 1
app/common/dao/store/shipping/ShippingTemplateDao.php

@@ -89,7 +89,7 @@ class ShippingTemplateDao  extends BaseDao
89 89
 //        return ($this->getModel())::getDB()->where('mer_id',$merId)->field('shipping_template_id,name')->select();
90 90
         $list = ($this->getModel())::getDB()->where('mer_id',$merId)->field('shipping_template_id,name')->select()->toArray();
91 91
         $default = ['shipping_template_id' => 105, 'name' => '默认包邮'];//默认
92
-        $list[] = $default;
92
+        array_unshift($list, $default);
93 93
         return $list;
94 94
     }
95 95
 

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

@@ -418,8 +418,12 @@ class ProductRepository extends BaseRepository
418 418
                 $value['plate_mer_profit'] = $value['gong_mer_profit'];
419 419
 
420 420
                 $sku = '';
421
-                if (isset($value['detail']) && is_array($value['detail'])) {
421
+                if (isset($value['detail']) && is_array($value['detail']) && count($value['detail']) > 0) {
422 422
                     $sku = implode(',', $value['detail']);
423
+                } else {
424
+                    // 单规格情况,detail填充默认内容
425
+                    $value['detail'] = ['默认'];
426
+                    $sku = '默认';
423 427
                 }
424 428
                 $product_data = Db::name('store_product')->where('product_id', $id)->value('spu_id');
425 429
                 if ($product_data) {
@@ -1012,6 +1016,11 @@ class ProductRepository extends BaseRepository
1012 1016
         }
1013 1017
 
1014 1018
         $res['isRelation'] = $isRelation ?? false;
1019
+        foreach ($res['attrValue'] as $k => $value) {//兜底单规格老商品,如果没有那就填充默认
1020
+            if (empty($value['sku'])) {
1021
+                $res['attrValue'][$k]['sku'] = '默认';
1022
+            }
1023
+        }
1015 1024
         $res['sku'] = $this->detailAttrValue($res['attrValue'], $userInfo, $res['product_type']);
1016 1025
         $res['sales'] = $res['sales'] + $res['ficti'];
1017 1026
         $res['replayData'] = app()->make(ProductReplyRepository::class)->getReplyRate($res['product_id']);