Przeglądaj źródła

运输系统WMS接口

LD 6 lat temu
rodzic
commit
24bad60369

+ 85 - 0
app/Http/Controllers/WMSWaybillController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\WMSWaybill;
+use Illuminate\Http\Request;
+
+class WMSWaybillController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\WMSWaybill  $wMSWaybill
+     * @return \Illuminate\Http\Response
+     */
+    public function show(WMSWaybill $wMSWaybill)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\WMSWaybill  $wMSWaybill
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(WMSWaybill $wMSWaybill)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\WMSWaybill  $wMSWaybill
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, WMSWaybill $wMSWaybill)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\WMSWaybill  $wMSWaybill
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(WMSWaybill $wMSWaybill)
+    {
+        //
+    }
+}

+ 85 - 0
app/Http/Controllers/WMSWaybillOrderController.php

@@ -0,0 +1,85 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\WMSWaybillOrder;
+use Illuminate\Http\Request;
+
+class WMSWaybillOrderController extends Controller
+{
+    /**
+     * Display a listing of the resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function index()
+    {
+        //
+    }
+
+    /**
+     * Show the form for creating a new resource.
+     *
+     * @return \Illuminate\Http\Response
+     */
+    public function create()
+    {
+        //
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @return \Illuminate\Http\Response
+     */
+    public function store(Request $request)
+    {
+        //
+    }
+
+    /**
+     * Display the specified resource.
+     *
+     * @param  \App\WMSWaybillOrder  $wMSWaybillOrder
+     * @return \Illuminate\Http\Response
+     */
+    public function show(WMSWaybillOrder $wMSWaybillOrder)
+    {
+        //
+    }
+
+    /**
+     * Show the form for editing the specified resource.
+     *
+     * @param  \App\WMSWaybillOrder  $wMSWaybillOrder
+     * @return \Illuminate\Http\Response
+     */
+    public function edit(WMSWaybillOrder $wMSWaybillOrder)
+    {
+        //
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \App\WMSWaybillOrder  $wMSWaybillOrder
+     * @return \Illuminate\Http\Response
+     */
+    public function update(Request $request, WMSWaybillOrder $wMSWaybillOrder)
+    {
+        //
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  \App\WMSWaybillOrder  $wMSWaybillOrder
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy(WMSWaybillOrder $wMSWaybillOrder)
+    {
+        //
+    }
+}

+ 85 - 4
app/Http/Controllers/api/thirdPart/flux/WaybillController.php

@@ -3,17 +3,98 @@
 namespace App\Http\Controllers\Api\thirdPart\flux;
 
 use App\Http\Controllers\Controller;
-use App\RejectedBillItem;
 use App\Store;
-use App\WMSReflectReceive;
-use App\WMSReflectReceiveSku;
+use App\Waybill;
+use App\WMSWaybill;
+use App\WMSWaybillOrder;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Validator;
 use Zttp\Zttp;
 
 class WaybillController extends Controller
 {
 
-    public function accomplishToWMS(Store $store,array $inputs)
+    public function new_(Request $request)
     {
+        $errors=$this->validatorForNew($request->all())->errors();
+        if(count($errors)>0){
+            $this->log(__METHOD__, 'error_' . __FUNCTION__, json_encode($request->getContent()));
+            (new Controller())->log(__METHOD__,'error_'.__FUNCTION__,'fields wrong, see Errors report please.'.'|'.json_encode($request).'|'.json_encode($errors));
+            return response()->json(['response'=>['return'=>['returnFlag'=>'0','returnCode'=>'0001','returnDesc'=>'消息处理失败:Failure','resultInfo'=>'',
+                'errors'=>$errors]]])
+                ->setEncodingOptions(JSON_UNESCAPED_UNICODE);
+        }
+        $receivedInputtings=$request->input('request');
+        foreach ($receivedInputtings as $receiveInputting){
+            if(!WMSWaybill::create($receiveInputting)){
+                Controller::logS(__METHOD__,'error_'.__FUNCTION__,'运单WMS写入错误'.'|'.json_encode($receiveInputting));
+                return response()->json(['response'=>['return'=>['returnFlag'=>'0','returnCode'=>'0001','returnDesc'=>'运单WMS写入错误'.'|'
+                    .json_encode($receiveInputting),'resultInfo'=>'']]])
+                    ->setEncodingOptions(JSON_UNESCAPED_UNICODE);
+            }
+            foreach ($receiveInputting['order_list'] as $orderInputting){
+                if(!WMSWaybillOrder::create($orderInputting)){
+                    Controller::logS(__METHOD__,'error_'.__FUNCTION__,'运单订单行WMS写入错误'.'|'.json_encode($orderInputting));
+                    return response()->json(['response'=>['return'=>['returnFlag'=>'0','returnCode'=>'0001','returnDesc'=>'运单订单行WMS写入错误'.'|'
+                        .json_encode($orderInputting),'resultInfo'=>'']]])
+                        ->setEncodingOptions(JSON_UNESCAPED_UNICODE);
+                }
+            }
+        }
+        return response()->json(['response'=>['return'=>['returnFlag'=>'1','returnCode'=>'0000','returnDesc'=>'正确接收','resultInfo'=>'']]])
+            ->setEncodingOptions(JSON_UNESCAPED_UNICODE);
+
+
+    }
+
+    protected function validatorForNew(array $data)
+    {
+        return Validator::make($data, [
+            'request' => ['required', 'array', 'min:1'],
+            'request.*.OrderNo' => ['required', 'string', 'max:191','unique:w_m_s_waybills,OrderNo'],
+            'request.*.CustomerID' => ['required', 'string', 'max:191'],
+            'request.*.CarrierID' => ['required', 'string', 'max:191'],
+            'request.*.ConsigneeName' => ['nullable', 'string', 'max:191'],
+            'request.*.C_Tel' => ['nullable', 'string', 'max:191'],
+            'request.*.C_Address' => ['required', 'string', 'max:191'],
+            'request.*.C_Province' => ['required', 'string', 'max:191'],
+            'request.*.C_City' => ['nullable', 'string', 'max:191'],
+            'request.*.C_District' => ['nullable', 'string', 'max:191'],
+            'request.*.order_list' => ['required', 'array', 'min:1'],
+            'request.*.order_list.*.SKU_Descr_c' => ['nullable', 'string', 'max:191'],
+            'request.*.order_list.*.SKU' => ['required', 'string', 'max:191'],
+            'request.*.order_list.*.Alternate_sku1' => ['required', 'string', 'max:191'],
+            'request.*.order_list.*.Qtyordered_each' => ['required', 'string', 'max:191'],
+            'request.*.order_list.*.Cubic' => ['nullable', 'string', 'max:191'],
+            'request.*.order_list.*.GrossWeight' => ['nullable', 'string', 'max:191'],
+            'request.*.order_list.*.NetWeight' => ['nullable', 'string', 'max:191'],
+        ]);
+    }
+
+    public function accomplishToWMS(Waybill $waybill)
+    {
+        $json="
+                {
+                    \"request\": [
+                        {
+                            \"OrderNo\": \"{$waybill['wms_bill_number']}\",
+                            \"DELIVERYNO\": \"{$waybill['waybill_number']}\",
+                        }
+                    ]
+                }
+                ";
+        $sendingJson = json_decode($json,true);
+        $url=url(config('api.flux.waybill.new'));
+        $response = Zttp::post($url, $sendingJson);
+        $responseJson = $response->json();
+        if(!$responseJson||!isset($responseJson['Response'])||!$responseJson['Response']['return']['returnFlag']=='1'){
+            if(config('api.jianshang_rejecteds_log_switch'))Controller::logS(__METHOD__,'error_'.__FUNCTION__,"向WMS提交运单失败!!SO单号:{$waybill['wms_bill_number']}。返回:{$response->body()}",Auth::user()['id']);
+            return false;
+        }
+        if(config('api.jianshang_rejecteds_log_switch'))Controller::logS(__METHOD__,''.__FUNCTION__,"向WMS提交运单成功,SO单号:{$waybill['wms_bill_number']}。返回:{$response->body()}",Auth::user()['id']);
+        return true;
+
     }
 
 }

+ 13 - 0
app/WMSWaybill.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class WMSWaybill extends Model
+{
+    //
+    protected $fillable=['OrderNo','CustomerID','CarrierID','ConsigneeName',
+        'C_Tel','C_Address','C_Province','C_City','C_District'];
+
+}

+ 11 - 0
app/WMSWaybillOrder.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class WMSWaybillOrder extends Model
+{
+    protected $fillable = ['OrderNo','SKU_Descr_c','SKU','Alternate_sku1','Qtyordered_each',
+        'Cubic','GrossWeight','NetWeight'];
+}

+ 12 - 0
database/factories/WMSWaybillFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\WMSWaybill;
+use Faker\Generator as Faker;
+
+$factory->define(WMSWaybill::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 12 - 0
database/factories/WMSWaybillOrderFactory.php

@@ -0,0 +1,12 @@
+<?php
+
+/** @var \Illuminate\Database\Eloquent\Factory $factory */
+
+use App\WMSWaybillOrder;
+use Faker\Generator as Faker;
+
+$factory->define(WMSWaybillOrder::class, function (Faker $faker) {
+    return [
+        //
+    ];
+});

+ 39 - 0
database/migrations/2020_04_28_141248_create_w_m_s_waybills_table.php

@@ -0,0 +1,39 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateWMSWaybillsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('w_m_s_waybills', function (Blueprint $table) {
+            $table->string('OrderNo')->index()->comment('SO编号');
+            $table->string('CustomerID')->nullable()->comment('客户');
+            $table->string('CarrierID')->nullable()->comment('承运人');
+            $table->string('ConsigneeName')->nullable()->comment('收货人姓名');
+            $table->string('C_Tel')->nullable()->comment('收货人电话');
+            $table->string('C_Address')->nullable()->comment('收货地址');
+            $table->string('C_Province')->nullable()->comment('省');
+            $table->string('C_City')->nullable()->comment('市');
+            $table->string('C_District')->nullable()->comment('区');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('w_m_s_waybills');
+    }
+}

+ 39 - 0
database/migrations/2020_04_28_141405_create_w_m_s_waybill_orders_table.php

@@ -0,0 +1,39 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateWMSWaybillOrdersTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('w_m_s_waybill_orders', function (Blueprint $table) {
+            $table->bigIncrements('id');
+            $table->string('OrderNo')->index()->comment('SO单号');
+            $table->string('SKU_Descr_c')->nullable()->comment('商品名称');
+            $table->string('SKU')->nullable()->comment('商品编码');
+            $table->string('Alternate_sku1')->nullable()->comment('条码');
+            $table->string('Qtyordered_each')->nullable()->comment('数量');
+            $table->string('Cubic')->nullable()->comment('体称');
+            $table->string('GrossWeight')->nullable()->comment('毛重');
+            $table->string('NetWeight')->nullable()->comment('净重');
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('w_m_s_waybill_orders');
+    }
+}

+ 2 - 54
package-lock.json

@@ -3016,11 +3016,6 @@
             "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==",
             "dev": true
         },
-        "dompurify": {
-            "version": "1.0.11",
-            "resolved": "https://registry.npm.taobao.org/dompurify/download/dompurify-1.0.11.tgz",
-            "integrity": "sha1-/g9KQNFH98674xpQoTV1Oc/B600="
-        },
         "domutils": {
             "version": "1.7.0",
             "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.7.0.tgz",
@@ -5360,7 +5355,8 @@
         "jquery": {
             "version": "3.4.1",
             "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz",
-            "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw=="
+            "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==",
+            "dev": true
         },
         "js-cookie": {
             "version": "2.2.0",
@@ -8185,38 +8181,6 @@
             "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=",
             "dev": true
         },
-        "simple-hotkeys": {
-            "version": "1.0.3",
-            "resolved": "https://registry.npm.taobao.org/simple-hotkeys/download/simple-hotkeys-1.0.3.tgz",
-            "integrity": "sha1-R6W8NTYspzOWEb0JqE+jeBiwu8Y=",
-            "requires": {
-                "jquery": "2.x",
-                "simple-module": "~2.0.5"
-            },
-            "dependencies": {
-                "jquery": {
-                    "version": "2.2.4",
-                    "resolved": "https://registry.npm.taobao.org/jquery/download/jquery-2.2.4.tgz",
-                    "integrity": "sha1-LInWiJterFIqfuoywUUhVZxsvwI="
-                },
-                "simple-module": {
-                    "version": "2.0.6",
-                    "resolved": "https://registry.npm.taobao.org/simple-module/download/simple-module-2.0.6.tgz",
-                    "integrity": "sha1-zsglAyX4x/V19Kp1yRmzg5amA3s=",
-                    "requires": {
-                        "jquery": "2.x"
-                    }
-                }
-            }
-        },
-        "simple-module": {
-            "version": "3.0.3",
-            "resolved": "https://registry.npm.taobao.org/simple-module/download/simple-module-3.0.3.tgz",
-            "integrity": "sha1-rVJ2Z4XSfNlCfuhkWknkEZlyWpI=",
-            "requires": {
-                "jquery": "^3.0.0"
-            }
-        },
         "simple-swizzle": {
             "version": "0.2.2",
             "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
@@ -8234,22 +8198,6 @@
                 }
             }
         },
-        "simple-uploader": {
-            "version": "3.0.0",
-            "resolved": "https://registry.npm.taobao.org/simple-uploader/download/simple-uploader-3.0.0.tgz",
-            "integrity": "sha1-wJ9wbxz8vqH+eA41dZpoOxM21NE=",
-            "requires": {
-                "jquery": "~3.1.0",
-                "simple-module": "~3.0.0"
-            },
-            "dependencies": {
-                "jquery": {
-                    "version": "3.1.1",
-                    "resolved": "https://registry.npm.taobao.org/jquery/download/jquery-3.1.1.tgz",
-                    "integrity": "sha1-NHwcIcfgBBFeCk2jLOzgQfrTyKM="
-                }
-            }
-        },
         "slash": {
             "version": "1.0.0",
             "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz",

+ 6 - 0
routes/api/thirdPart/flux.php

@@ -20,3 +20,9 @@ Route::post('package/new', "PackageController@new_");//增加新波次消息
 */
 //请求数据,查询库单据是否存在
 Route::post('process/getProcessContent', "ProcessController@getProcessContent");//增加新波次消息
+
+/*
+文件地址前缀:/api/thirdPart/flux/waybill
+*/
+//请求数据,查询库单据是否存在
+Route::post('waybill/new', "WaybillController@new_");//增加运输单消息