root 1 year ago
parent
commit
442b043095

+ 48 - 4
app/Http/Controllers/Api/TestController.php

@@ -4,17 +4,61 @@ namespace App\Http\Controllers\Api;
 
 
 use App\Model\BoxDetail;
+use App\Service\Box\BoxHookService;
 use App\Service\MeasureService;
 use Illuminate\Http\Request;
 
 
 class TestController extends BaseController
 {
-    public function aa(Request $request)
-    {
-        $model = new BoxDetail(['channel'=>date('YmdHis')]);
-        var_dump($model);
 
+
+
+    public function boxInsert(){
+        $data = [
+            'out_order_no' => 'test123',
+            'ext_1' => '1',
+            'ext_2' => '2',
+            'ext_3' => '3',
+            'ext_4' => '4',
+            'ext_5' => '5',
+            'detail' => [
+                [
+                    'top_id' => '1',
+                    'code' => '001',
+                    'title' => '产品名称',
+                    'ext_1' => '1',
+                    'ext_2' => '2',
+                    'ext_3' => '3',
+                    'ext_4' => '4',
+                    'ext_5' => '5',
+                ],[
+                    'top_id' => '2',
+                    'code' => '002',
+                    'title' => '产品名称1',
+                    'ext_1' => '11',
+                    'ext_2' => '22',
+                    'ext_3' => '33',
+                    'ext_4' => '44',
+                    'ext_5' => '55',
+                ],
+            ],
+        ];
+
+
+        $service = BoxHookService::getInstance();
+
+        list($status,$msg) = $service->boxInsert($data);
+        var_dump($status);
+        var_dump($msg);
+    }
+
+    public function aa(){
+        $service = BoxHookService::getInstance();
+
+        list($status,$msg) = $service->boxDetail(['order_no'=>'202306130543108902']);
+        var_dump($status);
+        var_dump($msg);
     }
 
 

+ 1 - 1
app/Model/BoxDetail.php

@@ -19,7 +19,7 @@ class BoxDetail extends Model
     protected $dateFormat = 'U';
     protected $guarded = [];
 
-    protected $month = [
+    public $month = [
         1 => '01_03',
         2 => '01_03',
         3 => '01_03',

+ 39 - 11
app/Service/Box/BoxHookService.php

@@ -47,8 +47,8 @@ class BoxHookService extends Service
         list($status,$box) = $this->dealBox($box,$data);
         if(!$status) return [false,$box];
         $box->save();
-        list($status,$box) =  $this->boxDetailInsert($data);
-        if(!$status) return [false,$box];
+        list($status,$msg) =  $this->boxDetailInsert($data);
+        if(!$status) return [false,$msg];
 
         return [true,$box];
     }
@@ -101,12 +101,12 @@ class BoxHookService extends Service
      * @return array
      */
     public function dealBoxDetail($data,$order_no,$out_order_no){
-
         $insert = [];
+        $time = time();
         foreach ($data as $v){
-            if(!isset($data['top_id'])) return [false,'top_id is not exist'];
-            if(!isset($data['code'])) return [false,'code is not exist'];
-            if(!isset($data['title'])) return [false,'title is not exist'];
+            if(!isset($v['top_id'])) return [false,'top_id is not exist'];
+            if(!isset($v['code'])) return [false,'code is not exist'];
+            if(!isset($v['title'])) return [false,'title is not exist'];
 
             $insert[] = [
                 'order_no' => $order_no,
@@ -114,11 +114,14 @@ class BoxHookService extends Service
                 'top_id' => $v['top_id'],
                 'code' => $v['code'],
                 'title' => $v['title'],
-                'ext_1' => isset($data['ext_1']) ? $data['ext_1'] : '',
-                'ext_2' => isset($data['ext_2']) ? $data['ext_2'] : '',
-                'ext_3' => isset($data['ext_3']) ? $data['ext_3'] : '',
-                'ext_4' => isset($data['ext_4']) ? $data['ext_4'] : '',
-                'ext_5' => isset($data['ext_5']) ? $data['ext_5'] : '',
+                'type' => isset($v['type'])?$v['type'] : 1,
+                'crt_time' => $time,
+                'upd_time' => $time,
+                'ext_1' => isset($v['ext_1']) ? $v['ext_1'] : '',
+                'ext_2' => isset($v['ext_2']) ? $v['ext_2'] : '',
+                'ext_3' => isset($v['ext_3']) ? $v['ext_3'] : '',
+                'ext_4' => isset($v['ext_4']) ? $v['ext_4'] : '',
+                'ext_5' => isset($v['ext_5']) ? $v['ext_5'] : '',
 
             ];
         }
@@ -136,6 +139,31 @@ class BoxHookService extends Service
         return date('YmdHis').rand(1000,9999);
     }
 
+    /**
+     * @param $data
+     * @return array
+     */
+    public function boxList($data){
+        $box = new Box();
+        $list = $this->limit($box,'*',$data);
+
+        return [true,$list];
+
+    }
+
+    public function boxDetail($data){
+        $order_no = $data['order_no'];
+
+        $box = new BoxDetail(['channel'=>$order_no]);
+
+        $list = $this->limit($box,'*',$data);
+
+        return [true,$list];
+    }
+
+
+
+
 
 
 }