Эх сурвалжийг харах

客户模块 阶段性提交 by 'zengjun'

ajun 5 жил өмнө
parent
commit
9ad7fe9186

+ 18 - 4
app/Http/Controllers/OrderIssueController.php

@@ -3,10 +3,18 @@
 namespace App\Http\Controllers;
 
 use App\OrderIssue;
+use App\Services\OrderIssueService;
 use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Gate;
 
 class OrderIssueController extends Controller
 {
+
+    public function __construct()
+    {
+        app()->bind("OrderIssueService",OrderIssueService::class);
+    }
+
     /**
      * search orderissue
      *
@@ -14,14 +22,14 @@ class OrderIssueController extends Controller
      */
     public function index()
     {
-        //
+        return view('order/issue/index');
     }
 
     /**
      * 绩效
      */
     public function performance(Request $request){
-
+        return view('order/issue/performance');
     }
 
     /**
@@ -29,7 +37,7 @@ class OrderIssueController extends Controller
      * @param Request $request
      */
     public function workLoad(Request $request){
-
+        return view('order/issue/workload');
     }
 
     /**
@@ -37,7 +45,13 @@ class OrderIssueController extends Controller
      * @param Request $request
      */
     public function orderIssueTag(Request $request){
-
+        if(!Gate::allows('订单管理-订单问题件生成')){ return ['success'=>false,'fail_info'=>'没有对应权限']; }
+        if(!$request->input('orderNos')){
+            return ['success'=>false,'fail_info'=>'没有传入的订单编号'];
+        }
+        $orderIssueService = app('OrderIssueService');
+        $meg =  $orderIssueService->orderIssueTag($request);
+        return $meg;
     }
 
 

+ 16 - 1
app/Order.php

@@ -10,7 +10,11 @@ class Order extends Model
     //
     use ModelTimeFormat;
 
-    protected $fillable = ['create_at','shop_id','logistic_number','logistic_id','consignee_name','consignee_phone','province','city','district','address'];
+    protected $fillable = ['created_at','code','shop_id','owner_id','logistic_number','logistic_id','consignee_name','consignee_phone','province','city','district','address','wms_status'];
+
+    protected $appends = [
+        'creator',
+    ];
 
     public function logistic(){
         return $this->belongsTo('App/logistic','logistic_id','id');
@@ -28,4 +32,15 @@ class Order extends Model
         return $this->hasOne('App/OrderOnTop','order_id','id');
     }
 
+    public function setCreatorAttribute ($id,$user_id){
+        Sign::updateOrCreate(['signable_type'=>'orders','signable_id'=>$id,'field'=>'creator','mark'=>$user_id]);
+    }
+
+    public function getCreatorAttribute(){
+       return  $this->hasOne('App\Sign','signable_id','id')
+            ->where('signable_type','orders')
+            ->where('field','creator')
+            ->value('mark');
+    }
+
 }

+ 16 - 0
app/OrderIssue.php

@@ -14,6 +14,10 @@ class OrderIssue extends Model
         'situation_explain', 'order_issue_type_id','result_explain','second_order_id','second_logistic_number',
         'final_status','logistic_indemnity_money','logistic_express_remission','baoshi_indemnity_money','baoshi_express_remission','user_workgroup_id'];
 
+    protected $appends = [
+        'creator',
+    ];
+
     public function order(){
         return $this->belongsTo('App/Order','order_id','id');
     }
@@ -34,4 +38,16 @@ class OrderIssue extends Model
         return $this->belongsTo('App/Order','second_order_id','id');
     }
 
+    public function setCreatorAttribute ($id,$user_id){
+        Sign::updateOrCreate(['signable_type'=>'orders','signable_id'=>$id,'field'=>'creator','mark'=>$user_id]);
+    }
+
+    public function getCreatorAttribute(){
+        return  $this->hasOne('App\Sign','signable_id','id')
+            ->where('signable_type','orders')
+            ->where('field','creator')
+            ->value('mark');
+    }
+
+
 }

+ 65 - 0
app/Services/OrderIssueService.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace App\Services;
+
+use App\Authority;
+use App\Logistic;
+use App\OracleDOCOrderHeader;
+use App\OrderIssue;
+use App\Owner;
+use App\Shop;
+use App\Sign;
+use App\Order;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\DB;
+
+class OrderIssueService
+{
+
+    public function __construct()
+    {
+        app()->bind("OrderService", OrderService::class);
+    }
+
+    public function orderIssueTag(Request $request)
+    {
+
+        $orderNos = $request->input('orderNos');
+        $meg = ['success' => false];
+        if ($this->verifyOrderIssue($request)) {
+            $meg['fail_info'] = '传入订单编号中对应的订单问题已有生成';
+            return $meg;
+        }
+        foreach ($orderNos as $orderNo) {
+            $this->createOrFind($orderNo);
+        }
+        $meg['success'] = '选中订单已标记为问题订单';
+        return $meg;
+    }
+
+    public function verifyOrderIssue(Request $request)
+    {
+        $orderIds = $request->input('orderNos');
+        $orders = Order::whereIn('code', $orderIds)->get();
+        if (count($orders) == 0) {
+            return false;
+        }
+        foreach ($orders as $order) {
+            $order_ids[] = $order->id;
+        }
+        $count = OrderIssue::whereIn('order_id', $order_ids)->count();
+        return $count != 0;
+    }
+
+    public function createOrFind($ordeNo)
+    {
+        $orderService = app('OrderService');
+        $order = $orderService->createOrFindByOrderHead($ordeNo);
+
+        $arr = [
+            'order_id' => $order->value('id'),
+        ];
+        return OrderIssue::create($arr);
+    }
+}

+ 51 - 0
app/Services/OrderService.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Services;
+
+
+use App\Logistic;
+use App\OracleDOCOrderHeader;
+use App\Order;
+use App\Owner;
+use App\Shop;
+
+Class OrderService
+{
+    public function createOrFindByOrderHead($oracleOrderNo){
+        $order = Order::where('code',$oracleOrderNo)->first();
+        if($order == null){
+            $orderHeadAttr =  OracleDOCOrderHeader::where('OrderNo',trim($oracleOrderNo,"'"))->first()->toArray();
+            // wms 货主
+            $customer_name = $orderHeadAttr['oracleBASCustomer_descr_c'];
+            $owner = Owner::updateOrCreate(['name'=>$orderHeadAttr['customerid'],'code'=>$customer_name]);
+            $owner_id = $owner->value('id');    // was 货主id
+
+            // 商铺id
+            $shop_name = $orderHeadAttr['issuepartyname'];
+            $shop = Shop::updateOrCreate(['name'=>$shop_name,'owner_id'=>$owner_id]);
+            $shop_Id = $shop->id;
+
+            // 承运商ID
+            $logistics =  Logistic::updateOrCreate(['name'=>$orderHeadAttr['carrierid'],'code'=>$orderHeadAttr['carriername']]);
+            $logistics_id = $logistics->value('id');
+            $arr = [
+                'code'=>$orderHeadAttr['orderno'],
+                'owner_id'=>$owner->value('id'),
+                'wms_status'=>$orderHeadAttr['oracleBASCode_codename_c'],
+                'created_at'=>$orderHeadAttr['addtime'],
+                'logistic_number'=>$orderHeadAttr['soreference5'],
+                'logistic_id'=>$logistics_id,
+                'shop_id'=>$shop_Id,
+                'consignee_name'=>$orderHeadAttr['c_contact'],
+                'consignee_phone'=>$orderHeadAttr['c_tel2'],
+                'province'=> $orderHeadAttr['c_province'],
+                'city'=>$orderHeadAttr['c_city'],
+                'district'=>$orderHeadAttr['c_district'],
+                'address'=>$orderHeadAttr['c_address1'],
+            ];
+            $order = Order::create($arr);
+        }
+        return $order;
+    }
+
+}

+ 1 - 1
app/Shop.php

@@ -10,5 +10,5 @@ class Shop extends Model
     //
     use ModelTimeFormat;
 
-    protected $fillable = ['name','code'];
+    protected $fillable = ['name','owner_id'];
 }

+ 2 - 1
database/migrations/2020_07_29_155624_create_orders_table.php

@@ -32,7 +32,8 @@ class CreateOrdersTable extends Migration
             $table->String("district")->nullable()->comment('区');
 
             $table->string("address")->nullable()->comment('地址');
-            $table->timestamp('create_at')->index();
+            $table->timestamp('created_at')->index();
+            $table->timestamp('updated_at')->index();
 //            $table->timestamps();
         });
     }

+ 2 - 2
database/migrations/2020_07_29_160704_create_shops_table.php

@@ -16,8 +16,8 @@ class CreateShopsTable extends Migration
         Schema::create('shops', function (Blueprint $table) {
             $table->id();
             $table->timestamps();
-            $table->string('name')->unique();
-            $table->string('code')->unique();
+            $table->string('name')->index();
+            $table->string('owner_id')->index();
         });
     }
 

+ 1 - 0
database/migrations/2020_07_29_160826_create_order_issues_table.php

@@ -16,6 +16,7 @@ class CreateOrderIssuesTable extends Migration
         Schema::create('order_issues', function (Blueprint $table) {
             $table->id();
             $table->timestamp('created_at')->index();
+            $table->timestamp('updated_at')->index();
             $table->integer('order_id')->index()->comment('订单');
             $table->enum('handle_status',['处理中','已完结'])->default('处理中')->comment('处理状态');
             $table->integer('rejected_bill_id')->index()->nullable()->comment('退回单');

+ 1 - 0
database/migrations/2020_07_29_164829_add_data_authorities_issue.php

@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Schema;
 class AddDataAuthoritiesIssue extends Migration
 {
     protected $authNames = [
+        "订单管理-订单问题件生成",
         "订单管理-问题件-查询",
         "订单管理-问题件-工作量",
         "订单管理-问题件-绩效统计"

+ 21 - 14
resources/js/queryForm/queryForm.js

@@ -551,10 +551,10 @@ const query = function getQueryForm(data) {
         })
         input.blur(function () {
             setTimeout(function () {
-                if (!select_div.is(':focus')) {
+                if (!ul_div.is(':focus')) {
                     ul_div.hide();
                 }
-            }, 1000);
+            }, 100);
         })
         select_div.focus(function () {
             ul_div.show();
@@ -566,6 +566,11 @@ const query = function getQueryForm(data) {
             ul_div.hide();
         })
         ul_div.hide();
+        ul_div.mouseleave(function () {
+            if(_data[condition.name].value){
+                _this.onsubmit();
+            }
+        });
         return div;
     }
 
@@ -620,15 +625,18 @@ const query = function getQueryForm(data) {
             li.click(function () {
                 let value = li.attr('value');
                 let dom_data = _data[name].value;
-                if (controlJsType(dom_data, ['undefined', 'null', 'string'])) {
+                if(!dom_data){
+                    dom_data = [];
+                }
+                if (controlJsType(dom_data,'string')){
                     dom_data = [dom_data];
                 }
                 if (dom_data.includes(value)) {
                     dom_data.splice(dom_data.indexOf(value), 1);
                 } else {
                     dom_data.push(value);
-                    dom_data = arrDuplicate(dom_data);
                 }
+                dom_data = arrDuplicate(dom_data);
                 let dom = {
                     name: ul.attr('name'),
                     type: 'select_multiple_select',
@@ -636,10 +644,10 @@ const query = function getQueryForm(data) {
                     select: dom_data,
                     mold: 'select_multiple_select'
                 };
+                modifyData(dom)
                 modifyData(dom);
                 redenerUl(ul);
                 isMultiple(ul.attr('name'));
-                _this.onsubmit();
             })
         })
     }
@@ -647,11 +655,7 @@ const query = function getQueryForm(data) {
     function isMultiple(name) {
         let label = $('#' + name + '_lab');
         let select = $('#' + name + '_sel');
-        let dom_data = _data[name].data;
-        console.log(_data[name],_data);
-        console.log(dom_data);
-        console.log(name);
-
+        let dom_data = _data[name].value;
         if (dom_data.length === 1 ) {
             select.show();
             select.val(dom_data[0]);
@@ -1088,12 +1092,15 @@ const query = function getQueryForm(data) {
                     }
                 } else if (key === 'page') {
                     _page = data[key];
-                }  else if(_data[key].type === 'select_multiple_select' && !data[key]){
-                    _data[key].value = data[key].split(',');
+                }  else if(_data[key].type === 'select_multiple_select' ){
+                    if(!_data[key]){
+                        _data[key].value = [];
+                    }else{
+                        _data[key].value = data[key].split(',');
+                    }
                 }else {
                     _data[key].value = data[key];
                 }
-                // console.log('key', key, typeof key);
             }
         }
     }
@@ -1232,4 +1239,4 @@ const query = function getQueryForm(data) {
         return string;
     }
 
-};
+};

+ 29 - 1
resources/views/order/index/delivering.blade.php

@@ -18,6 +18,8 @@
                         </div>
                     </span>
                     @can('订单管理-批量备注')<button @click="modal()" type="button" class="btn btn-sm ml-2 btn-outline-primary">批量备注追加</button>@endcan
+                    @can('订单管理-订单问题件生成')<button type="button"  @click="orderIssueTag()" type="button" class="btn btn-sm ml-2 btn-outline-primary ">标记问题件</button>@endcan
+
                 </div>
                 <div class="modal fade " style="top: 20%" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                     <div class="modal-dialog">
@@ -35,6 +37,7 @@
                         </div><!-- /.modal-content -->
                     </div><!-- /.modal -->
                 </div>
+
                 <table class="table table-sm table-striped table-bordered table-hover card-body mt-2 ml-3">
                     <tr class="text-nowrap">
                         <th>
@@ -462,7 +465,32 @@
                         return
                     }
                     order.is_unfold=false;
-                }
+                },
+                orderIssueTag(){
+                   // 标记问题单
+                    let _this=this;
+                    if(_this.checkData.length===0){
+                        tempTip.show('没有勾选记录');
+                        return
+                    }
+                    /*let OrderNos = _this.checkData.map(function(value){
+                        return "'"+value+"'";
+                    })*/
+                    // console.log(OrderNos);
+                    axios.post("{{url('order/issue/orderIssueTag')}}",{orderNos:_this.checkData}).then(function(res){
+                        if(res.data.success){
+                            tempTip.setDuration(3000);
+                            tempTip.showSuccess('已标记为问题件');
+                        }else{
+                            tempTip.show(res.data.fail_info);
+                        }
+
+                    }).catch(function(err){
+                        tempTip.setDuration(3000);
+                        tempTip.show('网络链接异常'+err);
+                    })
+
+                },
             },
         });
     </script>

+ 101 - 0
resources/views/order/issue/index.blade.php

@@ -0,0 +1,101 @@
+@extends('layouts.app')
+@section('title')问题件-查询@endsection
+
+@section('content')
+    @component("order.issue.menu")@endcomponent
+    <div class="container-fluid" id="wave_div">
+        <div style="min-width: 2000px;">
+            <div id="list" class="d-none">
+                <div id="form_div" style="min-width: 1950px;" class="bg-white"></div>
+                <table class="table table-sm table-striped table-bordered table-hover card-body mt-2" style="background: #fff;">
+                    <tr>。
+                        <th ></th>
+                        <th>原始运单号</th>
+                        <th>情况说明</th>
+                    </tr>
+                    <tr>
+                        <th>
+                            <lable for="all">
+                                <input id="all" type="checkbox" @click="checkAll($event)" />
+                            </lable>
+                        </th>
+                        <th>序号</th>
+                        <th>ID</th>
+                        <th>状态</th>
+                        <th>登记日期</th>
+                        <th>订单日期</th>
+                        <th>客户</th>
+                        <th>店铺</th>
+                        <th>原始订单号</th>
+                        <th>原始承运商</th>
+                        <th>原始运单号</th>
+                        <th>收货人名称</th>
+                        <th>收货人电话</th>
+                        <th>省</th>
+                        <th>市</th>
+                        <th>区</th>
+                        <th>收货人地址</th>
+                        <th>原始商品明细</th>
+                        <th>返回商品明细</th>
+                        <th>退单状态</th>
+                        <th>情况说明</th>
+                        <th>问题类别</th>
+                        <th>处理结果说明</th>
+                        <th>二次订单号</th>
+                        <th>二次承运商</th>
+                        <th>二次运单号</th>
+                        <th>二次商品明细</th>
+                        <th>最终转态</th>
+                        <th>承运商赔偿金额</th>
+                        <th>承运商快递减免</th>
+                        <th>宝石赔偿金额</th>
+                        <th>宝石快递减免</th>
+                        <th>事故责任方</th>
+                        <th>操作</th>
+                    </tr>
+{{--                    <tr v-for="(orderIssue,index) as orderIssues"></tr>--}}
+                </table>
+            </div>
+        </div>
+    </div>
+@endsection
+@section('lastScript')
+    <script type="text/javascript" src="{{asset('js/queryForm/queryForm.js')}}"></script>
+    <script>
+
+        let listVue = new Vue({
+            el:'#list',
+            data:{
+                {{--orderIssue:'{!!  !!}'--}}
+                checkDate:[],
+                from:'',
+            },
+            mounted:function(){
+                let data = [[
+                    {name:['startDate','endDate'],type:'dataTime_dataTime',tip:['订单起始日期','订单结束日期']},
+                    {name:'owners_id',type:'search_select',tip:'选择要显示的客户',placeholder:['客户',''],
+                        data:[{name:'',value:''}]
+                    },
+                    {
+
+                    }
+                ],
+                    []];
+                this.form = new query({
+                    el:'form_div',
+                    condition:data,
+                })
+                this.form.init();
+            },
+            methods:{
+
+            }
+        })
+
+
+    </script>
+@endsection
+
+
+
+

+ 1 - 1
resources/views/order/issue/menu.blade.php

@@ -6,7 +6,7 @@
             <ul class="nav nav-pills">
                 @can('订单管理-问题件-查询')
                     <li class="nav-item">
-                        <a class="nav-link" href="{{url('order/issue/index/')}}" :class="{active:isActive('issue',2)}">查询</a>
+                        <a class="nav-link" href="{{url('order/issue/index/')}}" :class="{active:isActive('index',3)}">查询</a>
                     </li> @endcan
                 @can('订单管理-问题件-工作量')
                     <li class="nav-item">

+ 25 - 1
resources/views/order/issue/performance.blade.php

@@ -1 +1,25 @@
-<?php
+@extends('layouts.app')
+@section('title')问题件-工作量@endsection
+
+@section('content')
+    @component("order.issue.menu")@endcomponent
+    <div class="container-fluid" id="wave_div">
+        <div style="min-width: 2000px;">
+            <div id="form_div" style="min-width: 1950px;" class="bg-white"></div>
+            <table class="table table-sm table-striped table-bordered table-hover card-body mt-2 ">
+                <td>
+
+                </td>
+            </table>
+
+        </div>
+    </div>
+
+@endsection
+@section('lastScript')
+    <script type="text/javascript" src="{{asset('js/queryForm/queryForm.js')}}"></script>
+    <script>
+
+    </script>
+
+@endsection

+ 22 - 1
resources/views/order/issue/workload.blade.php

@@ -1 +1,22 @@
-<?php
+@extends('layouts.app')
+@section('title')问题件-工作量@endsection
+
+@section('content')
+    @component("order.issue.menu")@endcomponent
+    <div class="container-fluid" id="wave_div">
+        <div style="min-width: 2000px;">
+            <div id="form_div" style="min-width: 1950px;" class="bg-white"></div>
+            <table class="table table-sm table-striped table-bordered table-hover card-body mt-2 ">
+
+            </table>
+
+        </div>
+    </div>
+
+@endsection
+@section('lastScript')
+    <script type="text/javascript" src="{{asset('js/queryForm/queryForm.js')}}"></script>
+    <script>
+
+    </script>
+@endsection

+ 1 - 0
routes/web.php

@@ -337,4 +337,5 @@ Route::group(['prefix'=>'order'],function(){
     Route::get('issue/workload','OrderIssueController@workLoad');
     // 标记问题订单
     Route::post('issue/orderIssueTag','OrderIssueController@orderIssueTag');
+
 });