Quellcode durchsuchen

修复:订单商品表未写入某些字段

萤火科技 vor 5 Jahren
Ursprung
Commit
aebbbdbc3a

+ 0 - 2
app/api/model/OrderGoods.php

@@ -12,8 +12,6 @@ declare (strict_types = 1);
 
 namespace app\api\model;
 
-use app\api\service\User as UserService;
-use app\common\exception\BaseException;
 use app\common\model\OrderGoods as OrderGoodsModel;
 
 /**

+ 6 - 6
app/api/service/order/Checkout.php

@@ -756,7 +756,7 @@ class Checkout extends BaseService
             'order_source' => $this->orderSource['source'],
             'order_source_id' => $this->orderSource['source_id'],
             'points_bonus' => $order['pointsBonus'],
-            'order_status' =>  OrderStatusEnum::NORMAL,
+            'order_status' => OrderStatusEnum::NORMAL,
             'store_id' => $this->storeId,
         ];
         if ($order['delivery'] == DeliveryTypeEnum::EXPRESS) {
@@ -783,14 +783,14 @@ class Checkout extends BaseService
                 'user_id' => $this->user['user_id'],
                 'store_id' => $this->storeId,
                 'goods_id' => $goods['goods_id'],
-                'goods_name' => $goods['goods_name'],
-                'image_id' => $goods['images'][0]['image_id'],
+                'goods_no' => $goods['goods_no'] ?: '',
+                'image_id' => (int)current($goods['goods_images'])['file_id'],
                 'deduct_stock_type' => $goods['deduct_stock_type'],
                 'spec_type' => $goods['spec_type'],
                 'goods_sku_id' => $goods['skuInfo']['goods_sku_id'],
-                'goods_props' => $goods['skuInfo']['goods_props'],
-                'content' => $goods['content'],
-                'goods_sku_no' => $goods['skuInfo']['goods_sku_no'],
+                'goods_props' => $goods['skuInfo']['goods_props'] ?: '',
+                'content' => $goods['content'] ?? '',
+                'goods_sku_no' => $goods['skuInfo']['goods_sku_no'] ?: '',
                 'goods_price' => $goods['skuInfo']['goods_price'],
                 'line_price' => $goods['skuInfo']['line_price'],
                 'goods_weight' => $goods['skuInfo']['goods_weight'],

+ 3 - 2
app/common/model/Goods.php

@@ -8,7 +8,7 @@
 // +----------------------------------------------------------------------
 // | Author: 萤火科技 <admin@yiovo.com>
 // +----------------------------------------------------------------------
-declare (strict_types = 1);
+declare (strict_types=1);
 
 namespace app\common\model;
 
@@ -262,7 +262,8 @@ class Goods extends BaseModel
         // 商品状态
         $status > 0 && $filter[] = ['status', '=', $status];
         // 获取商品列表数据
-        $data = $this->withoutField(['content'])
+        $data = $this
+            // ->withoutField(['content'])
             ->with(['images.file'])
             ->where($filter)
             ->where('is_delete', '=', 0)

+ 2 - 2
app/common/model/OrderGoods.php

@@ -8,7 +8,7 @@
 // +----------------------------------------------------------------------
 // | Author: 萤火科技 <admin@yiovo.com>
 // +----------------------------------------------------------------------
-declare (strict_types = 1);
+declare (strict_types=1);
 
 namespace app\common\model;
 
@@ -84,7 +84,7 @@ class OrderGoods extends BaseModel
      */
     public function setGoodsPropsAttr($value)
     {
-        return helper::jsonEncode($value);
+        return $value ? helper::jsonEncode($value) : '';
     }
 
     /**