zealerChina 1 gadu atpakaļ
vecāks
revīzija
9996fea98e

+ 2 - 2
application/common/model/MobileOrder.php

@@ -139,10 +139,10 @@ class MobileOrder extends Model
         unset($columns['password']);
         return $this->belongsTo(Admin::class)->field($columns);
     }
-    // // 和产品信息多对一的关系
+    // 和产品信息多对一的关系
     public function produce()
     {
-        return $this->belongsTo(Produce::class, 'api_goods_id', 'id');
+        return $this->belongsTo(Produce::class, 'produce_id', 'id');
     }
 
     public function getAddressAttr($a,$b){

+ 13 - 6
application/common/service/ZopOrderService.php

@@ -60,13 +60,13 @@ class ZopOrderService extends ZopBaseService
     public static function cuccPush(MobileOrder $order, Produce $produce)
     {
         // 1. 资源上传
-        $goodsId = $produce->goods_id ?? 0;
+        $goodsId = $produce->api_goods_id ?? 0;
         $channel = $produce->contact_code ?? '';
         $images = $produce->images ?? '';
         $resourceId = $produce->resource_id ?? 0;
 
         if (empty($resourceId)) {
-            if (empty($goodsId) || empty($channel) || empty($images)) {
+            if (empty($goodsId)) {
                 return self::error('上游编码为空');
             }
             if (empty($channel)) {
@@ -77,11 +77,18 @@ class ZopOrderService extends ZopBaseService
             }
             // 如果图片是地址的话, 就转换成base64
             if (strpos($images, 'http') === 0) {
-                $images = base64_encode(file_get_contents($images));
+                $imagesBase = base64_encode(file_get_contents($images));
+
+                // 获取图片 MIME 类型
+                $sizeInfo = getimagesize($images);
+                $mimeType = $sizeInfo['mime'];
+                
+                // 构建数据 URI
+                $images = 'data:' . $mimeType . ';base64,' . $imagesBase;
             }
             
             $resourceParams = [
-                'goods_id' => $goodsId,
+                'goodsId' => $goodsId,
                 'channel' => $channel,
                 'resourceContents' => [
                     [
@@ -100,8 +107,8 @@ class ZopOrderService extends ZopBaseService
     
             // 获取资源ID
             $resourceId = $resourceResult['data']['resourceId'] ?? '';
-            $order->resource_id = $resourceId;
-            $order->save();
+            $produce->resource_id = $resourceId;
+            $produce->save();
         }
 
         // 2. 客户资料校验