root vor 2 Jahren
Ursprung
Commit
5e63251f62

+ 47 - 0
app/Http/Controllers/Api/BoxController.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+
+use App\Service\Box\BoxService;
+use App\Service\Oa\OaService;
+use Illuminate\Http\Request;
+
+
+class BoxController extends BaseController
+{
+
+
+
+
+
+    public function boxIn(Request $request)
+    {
+
+
+        $service = new BoxService();
+        list($status,$data) = $service->boxIn($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+
+    }
+
+    public function boxDetail(Request $request)
+    {
+
+
+        $service = new BoxService();
+        list($status,$data) = $service->boxDetail($request->all());
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+
+    }
+}

+ 10 - 8
app/Http/Controllers/Api/TestController.php

@@ -13,9 +13,10 @@ class TestController extends BaseController
 
 
 
-    public function boxInsert(){
+    public function aa(){
         $data = [
             'out_order_no' => 'test123',
+            'top_id' => '1',
             'ext_1' => '1',
             'ext_2' => '2',
             'ext_3' => '3',
@@ -45,6 +46,7 @@ class TestController extends BaseController
         ];
 
 
+        var_dump(json_encode($data));die;
         $service = BoxHookService::getInstance();
 
         list($status,$msg) = $service->boxInsert($data);
@@ -52,13 +54,13 @@ class TestController extends BaseController
         var_dump($msg);
     }
 
-    public function aa(){
-        $service = BoxHookService::getInstance();
-
-        list($status,$msg) = $service->boxDetail(['order_no'=>'202306130543108902']);
-        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);
+//    }
 
 
 

+ 5 - 1
app/Service/Box/BoxHookService.php

@@ -44,6 +44,7 @@ class BoxHookService extends Service
         $box = new Box();
         $data['order_no'] = $this->setOrderNo();
         if(!isset($data['out_order_no'])) return [false,'out_order_no is not exist'];
+        if(!isset($data['top_id'])) return [false,'top_id is not exist'];
         list($status,$box) = $this->dealBox($box,$data);
         if(!$status) return [false,$box];
         $box->save();
@@ -64,12 +65,14 @@ class BoxHookService extends Service
 
         $box->order_no = $data['order_no'];
         $box->out_order_no = $data['out_order_no'];
+        $box->top_id = $data['top_id'];
         $box->ext_1 = isset($data['ext_1']) ? $data['ext_1'] : '';
         $box->ext_2 = isset($data['ext_2']) ? $data['ext_2'] : '';
         $box->ext_3 = isset($data['ext_3']) ? $data['ext_3'] : '';
         $box->ext_4 = isset($data['ext_4']) ? $data['ext_4'] : '';
         $box->ext_5 = isset($data['ext_5']) ? $data['ext_5'] : '';
 
+
         return [true,$box];
 
     }
@@ -145,7 +148,8 @@ class BoxHookService extends Service
      */
     public function boxList($data){
         $box = new Box();
-        $list = $this->limit($box,'*',$data);
+        if(!isset($data['id'])) return [false,'id not found'];
+        $list = $box->where('top_id',$data['id'])->get()->toArray();
 
         return [true,$list];
 

+ 136 - 0
app/Service/Box/BoxService.php

@@ -0,0 +1,136 @@
+<?php
+
+namespace App\Service\Box;
+
+
+
+use App\Model\Box;
+use App\Model\BoxDetail;
+use App\Model\Header_ext;
+use App\Model\SaleOrdersProduct;
+use App\Service\Service;
+
+/**
+ * 包装相关
+ * @package App\Models
+ */
+class BoxService extends Service
+{
+
+    protected static $instance;
+    protected static $box_header;
+    protected static $box_detail_header;
+    protected static $box_hook;
+
+    public function __construct(){
+
+        self::$box_header = Header_ext::where('type','box')->pluck('value','key')->toArray();
+        self::$box_detail_header = Header_ext::where('type','box_detail')->pluck('value','key')->toArray();
+        self::$box_hook = BoxHookService::getInstance();
+
+    }
+
+
+
+    /**
+     * 包装
+     * @param $data
+     * @return array
+     */
+    public function boxIn($data){
+
+//        $param = $data['param'];
+        $param = [
+            [
+                'id'=>716,
+                'param'=>[
+                    '1',
+                    '1'
+                ],
+            ],[
+                'id'=>723,
+                'param'=>[
+                    '40',
+                    '40'
+                ],
+            ],
+        ];
+
+        $ids = [];
+        $key_list = [];
+        foreach ($param as $v){
+            $ids[] = $v['id'];
+            $total = 0;
+
+            foreach ($v['param'] as $vv){
+                $total += $vv;
+            }
+            $key_list[$v['id']] = [
+                'detail' => $v['param'],
+                'total' => $total,
+            ];
+        }
+
+        $product_list = SaleOrdersProduct::wherein('id',$ids)->get()->toArray();
+        foreach ($product_list as $v){
+            $num_list = $key_list[$v['id']];
+            $total = $num_list['total'];
+            $detail = $num_list['detail'];
+            $un_box_num = $v['order_quantity'] - $v['box_num'];
+            if($num_list['total'] > $un_box_num) return [false,$v['product_title'].'数量不足'];
+
+        }
+
+        //$data = [
+        //            'out_order_no' => 'test123',
+        //            'top_id' => '1',
+        //            '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',
+        //                ],
+        //            ],
+        //        ];
+        return [true,''];
+    }
+
+
+    /**
+     * 包装详情1
+     * @param $data
+     * @return array
+     */
+    public function boxDetail($data){
+        list($status,$data) = self::$box_hook->boxList($data);
+        if(!$status) return [false,$data];
+        return [true,$data];
+    }
+
+
+
+
+
+
+
+
+}

+ 25 - 0
app/Service/Service.php

@@ -3,6 +3,8 @@
 namespace App\Service;
 
 
+use Illuminate\Support\Facades\Cache;
+
 /**
  * 公用的公共服务
  * @package App\Models
@@ -232,4 +234,27 @@ class Service
 
         return $result;
     }
+
+    /**
+     * @param $key
+     * @return bool
+     */
+    function isLock($key){
+
+        if(Cache::has($key)){
+            $status = false;
+        }else{
+            $status = Cache::add($key,1,1);
+        }
+
+        return $status;
+    }
+
+
+    /**
+     * @param $key
+     */
+    function delLock($key){
+        Cache::forget($key);
+    }
 }

Datei-Diff unterdrückt, da er zu groß ist
+ 161 - 379
composer.lock


+ 8 - 3
routes/api.php

@@ -20,6 +20,7 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
 Route::any('login', 'Api\LoginController@login');
 Route::any('test', 'Api\TestController@aa');
 Route::any('getHeaderWord', 'Api\HeaderWordController@getHeaderWord');
+Route::any('deviceList', 'Api\Device\DeviceController@deviceList');
 Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('menuAdd', 'Api\SysMenuController@add');
     $route->any('menuEdit', 'Api\SysMenuController@edit');
@@ -140,11 +141,15 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('orderDetail', 'Api\OrderController@orderDetail');
 
     $route->any('tagDetail', 'Api\OrderTagController@tagDetail');
-    $route->any('boxDetail', 'Api\OrderBoxController@boxDetail');
     $route->any('transportDetail', 'Api\OrderTransportController@transportDetail');
-    $route->any('boxIn', 'Api\OrderBoxController@boxIn');
-    $route->any('boxOut', 'Api\OrderBoxController@boxOut');
     $route->any('boxTransport', 'Api\OrderTransportController@boxTransport');
     $route->any('transportConfirm', 'Api\OrderTransportController@transportConfirm');
     $route->any('deviceList', 'Api\Device\DeviceController@deviceList');
+
+
+    //请求表头信息
+    $route->any('getHeaderWord', 'Api\HeaderWordController@getHeaderWord');
+    //包装相关
+    $route->any('boxDetail', 'Api\BoxController@boxDetail');
+    $route->any('boxIn', 'Api\BoxController@boxIn');
 });

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.