root пре 1 година
родитељ
комит
2b73ef4ecb

+ 30 - 0
app/Http/Controllers/Api/HeaderWordController.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+
+use App\Service\HeaderWord\HeaderWordHookService;
+use App\Service\ProcessService;
+use Illuminate\Http\Request;
+
+
+class HeaderWordController extends BaseController
+{
+    public function getHeaderWord(Request $request)
+    {
+
+
+        $service =  HeaderWordHookService::getInstance();
+        $data = $request->all();
+        list($status,$data) = $service->getHeaderWord($data);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+
+    }
+
+
+}

+ 19 - 0
app/Model/HeaderWord.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Model;
+
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ *
+ * Class Unit
+ * @package App\Models
+ */
+class HeaderWord extends Model
+{
+    protected $table = "header_word"; //指定表
+    const CREATED_AT = 'crt_time';
+    const UPDATED_AT = 'upd_time';
+    protected $dateFormat = 'U';
+
+}

+ 4 - 0
app/Service/Box/BoxHookService.php

@@ -151,6 +151,10 @@ class BoxHookService extends Service
 
     }
 
+    /**
+     * @param $data
+     * @return array
+     */
     public function boxDetail($data){
         $order_no = $data['order_no'];
 

+ 51 - 0
app/Service/HeaderWord/HeaderWordHookService.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Service\HeaderWord;
+
+
+
+
+use App\Model\Header_ext;
+use App\Service\Service;
+
+/**
+ * 表头相关工厂模式
+ * @package App\Models
+ */
+class HeaderWordHookService extends Service
+{
+
+    protected static $instance;
+    protected static $header;
+    protected static $header_detail;
+
+    public function __construct(){
+
+    }
+
+    public static function getInstance(): self
+    {
+        if (self::$instance == null) {
+            self::$instance = new HeaderWordHookService();
+        }
+        return self::$instance;
+    }
+
+    public function getHeaderWord($data){
+
+        if(!isset($data['type'])) return [false,'not found type'];
+        $type = $data['type'];
+        $list = Header_ext::where('type',$type)->orderBy('sort','asc')->select('*')->get()->toArray();
+//        self::$header_detail = Header_ext::where('type',$type_detail)->pluck('value','key')->toArray();
+
+        return [true,$list];
+    }
+
+
+
+
+
+
+
+
+}

+ 173 - 0
app/Service/Transport/TransportHookService.php

@@ -0,0 +1,173 @@
+<?php
+
+namespace App\Service\Transport;
+
+
+
+use App\Model\Box;
+use App\Model\BoxDetail;
+use App\Model\Header_ext;
+use App\Service\Service;
+
+/**
+ * 发货相关工厂模式
+ * @package App\Models
+ */
+class TransportHookService extends Service
+{
+
+    protected static $instance;
+    protected static $transport_header;
+    protected static $transport_detail_header;
+
+    public function __construct(){
+
+        self::$transport_header = Header_ext::where('type','box')->pluck('value','key')->toArray();
+        self::$transport_detail_header = Header_ext::where('type','box_detail')->pluck('value','key')->toArray();
+
+    }
+
+    public static function getInstance(): self
+    {
+        if (self::$instance == null) {
+            self::$instance = new HeaderWordHookService();
+        }
+        return self::$instance;
+    }
+
+    /**
+     * 包装单新增
+     * @param $data
+     * @return array
+     */
+    public function boxInsert($data){
+        $box = new Box();
+        $data['order_no'] = $this->setOrderNo();
+        if(!isset($data['out_order_no'])) return [false,'out_order_no is not exist'];
+        list($status,$box) = $this->dealBox($box,$data);
+        if(!$status) return [false,$box];
+        $box->save();
+        list($status,$msg) =  $this->boxDetailInsert($data);
+        if(!$status) return [false,$msg];
+
+        return [true,$box];
+    }
+
+
+    /**
+     * @param $box
+     * @param $data
+     * @return mixed
+     */
+
+    public function dealBox($box,$data){
+
+        $box->order_no = $data['order_no'];
+        $box->out_order_no = $data['out_order_no'];
+        $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];
+
+    }
+
+
+    /**
+     * 包装单详情新增
+     * @param $data
+     * @return array
+     */
+    public function boxDetailInsert($data){
+        $order_no = $data['order_no'];
+        $out_order_no = $data['out_order_no'];
+        $box_detail = new BoxDetail(['channel'=>$order_no]);
+
+        if(!isset($data['detail'])) return [false,'detail is not exist'];
+
+        $insert = $data['detail'];
+
+        list($status,$insert) = $this->dealBoxDetail($insert,$order_no,$out_order_no);
+        if(!$status) return [false,$insert];
+        $box_detail->insert($insert);
+        return [true,''];
+    }
+
+    /**
+     * 包装单详情数据处理
+     * @param $data
+     * @return array
+     */
+    public function dealBoxDetail($data,$order_no,$out_order_no){
+        $insert = [];
+        $time = time();
+        foreach ($data as $v){
+            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,
+                'out_order_no' => $out_order_no,
+                'top_id' => $v['top_id'],
+                'code' => $v['code'],
+                'title' => $v['title'],
+                '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'] : '',
+
+            ];
+        }
+
+
+        return [true,$insert];
+    }
+
+
+    /**
+     * @return string
+     */
+    public function setOrderNo(){
+
+        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];
+
+    }
+
+    /**
+     * @param $data
+     * @return array
+     */
+    public function boxDetail($data){
+        $order_no = $data['order_no'];
+
+        $box = new BoxDetail(['channel'=>$order_no]);
+
+        $list = $this->limit($box,'*',$data);
+
+        return [true,$list];
+    }
+
+
+
+
+
+
+}

+ 1 - 0
routes/api.php

@@ -19,6 +19,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::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('menuAdd', 'Api\SysMenuController@add');
     $route->any('menuEdit', 'Api\SysMenuController@edit');