Browse Source

Merge branch 'master' into zengjun

# Conflicts:
#	app/Http/Controllers/TestController.php
#	app/Services/OwnerService.php
#	config/cache.php
ajun 5 years ago
parent
commit
a52ea86507

+ 3 - 2
app/Console/Commands/CreateOwnerBillReport.php

@@ -46,7 +46,8 @@ class CreateOwnerBillReport extends Command
             $year--;
             $lastMonth = '12';
         }else $lastMonth = ($month-1) < 10 ? "0".($month-1) : ($month-1);
-        $bills = DB::select(DB::raw("select owner_id,SUM(work_fee)+SUM(logistic_fee) as total from owner_fee_details where worked_at like ? GROUP BY owner_id"),[$year."-".$lastMonth."%"]);
+        $sql = "SELECT owner_id,SUM(work_fee)+SUM(logistic_fee) AS total FROM owner_fee_details WHERE worked_at LIKE ? AND (type = '发货' AND logistic_fee IS NOT NULL AND work_fee IS NOT NULL) OR (type <> '发货' AND work_fee IS NOT NULL)  GROUP BY owner_id";
+        $billDetails = DB::select(DB::raw($sql),[$year."-".$lastMonth."%"]);
 
         $areas = OwnerAreaReport::query()->with("ownerStoragePriceModel")->where("counting_month","like",$year."-".$lastMonth."%")->get();
         $map = [];
@@ -62,7 +63,7 @@ class CreateOwnerBillReport extends Command
             }
         }
 
-        $chunks = array_chunk($bills,50);
+        $chunks = array_chunk($billDetails,50);
         foreach ($chunks as $bills){
             $date = date('Y-m-d H:i:s');
             $createOwnerBillReport = [];

+ 8 - 17
app/Http/Controllers/LogController.php

@@ -7,6 +7,7 @@ use App\Services\LogService;
 use Exception;
 use Illuminate\Contracts\Foundation\Application;
 use Illuminate\Contracts\Pagination\LengthAwarePaginator;
+use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
 use Illuminate\Http\Response;
@@ -34,7 +35,8 @@ class LogController extends Controller
             !$request->has('created_at_end') &&
             !$request->has('operation') &&
             !$request->has('type') &&
-            !$request->has('description')
+            !$request->has('description') &&
+            !$request->has("is_exception")
         ) {
             $logs = Log::query()
                 ->orderBy('id', 'desc')
@@ -65,6 +67,11 @@ class LogController extends Controller
         if ($request->has('created_at_end')) {
             $query->where('created_at', '<=', $request->created_at_end);
         }
+        if ($request->has("is_exception")){
+            $query->where(function(Builder $query){
+                $query->where("type","like","ERROR%")->orWhere("type","like","EXCEPTION%");
+            });
+        }
         $query->orderByDesc('id');
         $logs = $query->paginate($request->paginate??50);
         return view('maintenance.log.index', ['logs' => $logs]);
@@ -81,22 +88,6 @@ class LogController extends Controller
         return view('maintenance.log.show', ['log' => $log]);
     }
 
-
-    /**
-     * Remove the specified resource from storage.
-     *
-     * @param Log $log
-     * @return array|Response
-     * @throws Exception
-     */
-    public function destroy(Log $log)
-    {
-//        if(!Gate::allows('物流公司-删除')){ return redirect(url('/'));  }
-//        app('LogService')->log(__METHOD__,__FUNCTION__,$log->toJson(),Auth::user()['id']);
-//        $re=$log->delete();
-//        return ['success'=>$re];
-    }
-
     public function syncRedisLogs()
     {
         LogService::syncRedisLogs();

+ 35 - 0
app/Http/Controllers/OrderCommodityAssignController.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Imports\UpdatePickZone;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Gate;
+use Maatwebsite\Excel\Facades\Excel;
+
+class OrderCommodityAssignController extends Controller
+{
+    public function index()
+    {
+        if(!Gate::allows('商品配置-查询')){ return redirect(url('denied'));  }
+        $assigns = app("OrderCommodityAssignService")->paginate();
+        return view("order.index.index",compact("assigns"));
+    }
+
+    public function import(Request $request)
+    {
+        if(!Gate::allows('商品配置-编辑')){ return ["success"=>false,"data"=>"无权操作!"];  }
+        $fileSuffix=$request->file('file')->getClientOriginalExtension();
+        if ($fileSuffix != 'xlsx' && $fileSuffix != 'xls' && $fileSuffix != 'csv')
+            return ['success'=>false,'data'=>'不支持该文件类型'];
+        ini_set('max_execution_time',2500);
+        ini_set('memory_limit','1526M');
+        $fileSuffix = ucwords($fileSuffix);
+
+        Excel::import(new UpdatePickZone(),$request->file('file')->path(),null,$fileSuffix);
+        if (Cache::has('commodityAssign'))return Cache::pull('commodityAssign');
+
+        return ["success"=>false,"data"=>"导入发生错误,数据无响应"];
+    }
+}

+ 7 - 1
app/Http/Controllers/StoreCheckingReceiveController.php

@@ -390,7 +390,7 @@ class StoreCheckingReceiveController extends Controller
         if(!Gate::allows('入库管理-盘收一体-盘收-编辑')){ return ['success'=>false, 'data'=>'无权操作!'];  }
         $id = $request->id ?? null;
         $counted_amount = $request->counted_amount ?? null;
-        if (!$id || !$counted_amount)return ['success'=>false, 'data'=>'参数传递错误!'];
+        if (!$id)return ['success'=>false, 'data'=>'参数传递错误!'];
         $item = app('StoreCheckingReceiveItemService')->find($id);
         if (!$item)return ['success'=>false, 'data'=>'被盘项不存在'];
         $params = ["counted_amount"=>$counted_amount];
@@ -435,4 +435,10 @@ class StoreCheckingReceiveController extends Controller
             app('LogService')->log(__METHOD__,"修改差异状态",json_encode($scr,JSON_UNESCAPED_UNICODE));
         }
     }
+
+    public function destroyItem(Request $request)
+    {
+        if (app("StoreCheckingReceiveItemService")->destroy($request->input("id")))return ["success"=>true];
+        return ["success"=>false,"data"=>"删除失败"];
+    }
 }

+ 2 - 16
app/Http/Controllers/TestController.php

@@ -12,7 +12,6 @@ use App\Console\Commands\SyncWMSOrderTask;
 use App\Events\CancelOrder;
 use App\Imports\OrderTrackingImport;
 use App\InventoryAccount;
-use App\Jobs\OrderCreateInstantBill;
 use App\LaborReport;
 use App\Log;
 use App\Logistic;
@@ -47,13 +46,11 @@ use App\Services\OrderService;
 use App\Services\OrderTrackingOwnerService;
 use App\Services\OrderTrackingService;
 use App\Services\OwnerService;
-use App\Services\ProvinceService;
 use App\Services\ShopService;
 use App\Services\StoreService;
 use App\Services\WarehouseService;
 use App\StoreCheckingReceiveItem;
 use App\User;
-use App\ValueStore;
 use App\Warehouse;
 use App\Waybill;
 use App\WaybillPriceModel;
@@ -159,19 +156,8 @@ class TestController extends Controller
     }
     public function t($a)
     {
-        dd(json_encode(
-            [[
-                "taskMode"      => 8,
-                "bins"=>[[
-                    "taskCode"  =>"TEST-BS2011160004",
-                    "binCode"   => "TESTBINCODE-0",
-                    "fromLocCode" => "BIN-IN1",
-                    //"toLocCode" => "BIN-OUT1",
-                ]],
-                "groupCode"     => 4,
-                "priority"      => 20,
-                "sequenceFlag"  => -1,
-            ]]        ));
+        $r = new \ReflectionClass('App\Http\Controllers\UnitsController');
+        dd($r->getMethods(),$r->getConstants());
     }
 
     public function updateLaborRemark(){

+ 153 - 0
app/Imports/UpdatePickZone.php

@@ -0,0 +1,153 @@
+<?php
+
+namespace App\Imports;
+
+use App\OracleDOCOrderDetail;
+use App\Services\LogService;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\DB;
+use Maatwebsite\Excel\Concerns\ToCollection;
+use Maatwebsite\Excel\Concerns\WithHeadingRow;
+use Maatwebsite\Excel\Imports\HeadingRowFormatter;
+
+HeadingRowFormatter::default('none');
+class UpdatePickZone implements ToCollection,WithHeadingRow
+{
+    /**
+    * @param Collection $collection
+    * @return bool
+    * @throws
+    */
+    public function collection(Collection $collection)
+    {
+        $row = $collection->first();
+        $headers = ["订单编号","商品条码","数量","生产日期","失效日期"];
+        foreach ($headers as $header){
+            if (!isset($row[$header])){
+                Cache::put("commodityAssign",["success"=>false, "data"=>"表头不存在“".$header."”"],86400);
+                return false;
+            }
+        }
+
+        $errors = [];
+        $ids = [];
+        foreach ($collection as $index=>$item){
+            if ($item["生产日期"]) $item["生产日期"] = formatExcelDate($item["生产日期"]);
+            if ($item["失效日期"]) $item["失效日期"] = formatExcelDate($item["失效日期"]);
+
+            if (!$item["订单编号"]){
+                $errors[] = "第“" . ($index + 2) . "”行订单编号为空";
+                continue;
+            }
+            if (!$item["商品条码"]){
+                $errors[] = "第“" . ($index + 2) . "”行商品条码为空";
+                continue;
+            }
+            if (!$item["生产日期"] && !$item["失效日期"]){
+                $errors[] = "第“" . ($index + 2) . "”行不存在日期";
+                continue;
+            }
+            $detail = OracleDOCOrderDetail::query()->select("customerid","sku")
+                ->where("orderno",$item["订单编号"])
+                ->whereHas("sku",function ($query)use($item){
+                    /** @var Builder $query */
+                    $query->where("alternate_sku1",$item["商品条码"]);
+                })->first();
+            if (!$detail){
+                $errors[] = "第“" . ($index + 2) . "”行未知订单商品";
+                continue;
+            }
+            $sql = "select INV_LOT_LOC_ID.LOCATIONID,INV_LOT_LOC_ID.LOTNUM,BAS_LOCATION.PICKZONE,INV_LOT_LOC_ID.QTY from INV_LOT_ATT LEFT JOIN
+                        INV_LOT_LOC_ID ON INV_LOT_ATT.LOTNUM = INV_LOT_LOC_ID.LOTNUM LEFT JOIN BAS_LOCATION ON INV_LOT_LOC_ID.LOCATIONID = BAS_LOCATION.LOCATIONID
+                    where INV_LOT_ATT.LOTNUM in (select LOTNUM from INV_LOT_LOC_ID where CUSTOMERID = ? AND SKU = ? GROUP BY LOTNUM)";
+            $bindings = [$detail->customerid,$detail->sku];
+            if ($item["生产日期"]){
+                $sql .= " AND LOTATT01 = ?";
+                $bindings[] = $item["生产日期"];
+            }else $sql .= " AND LOTATT01 IS NULL";
+            if ($item["失效日期"]){
+                $sql .= " AND LOTATT02 = ?";
+                $bindings[] = $item["失效日期"];
+            }else $sql .= " AND LOTATT02 IS NULL";
+
+            $lot = DB::connection("oracle")->select(DB::raw($sql),$bindings);
+            if (!$lot){
+                $errors[] = "第“" . ($index + 2) . "”行未找到库位";
+                continue;
+            }
+            $result = null;
+            if (count($lot)>1){
+                $min = null;
+                $max = null;
+                $map = [];
+                foreach ($lot as $i => $l){
+                    $qty = (int)$l->quty;
+                    $map[$qty] = $i;
+                    if ($qty >= (int)$item["数量"] && $qty<=$max)$max = $qty;
+                    if ($qty < (int)$item["数量"] && $qty>=$min)$min = $qty;
+                }
+                if ($max !== null)$result = $lot[$map[$max]];
+                else $result = $lot[$map[$min]];
+            }
+            if (count($lot) == 1)$result = $lot[0];
+            if ($result){dd($result);
+                try{
+                    $detail->update([
+                        "lotnum" => $result->lotnum,
+                        "pickzone" => $result->pickzone,
+                        "kitreferenceno" => '0',
+                        "d_edi_09" => '0',
+                        "d_edi_10" => '0',
+                    ]);
+                    DB::connection("oracle")->commit();
+                    LogService::log(__METHOD__,"SUCCESS-指定效期分配修改库位",json_encode($detail)." | ".json_encode($result));
+                    $order = app("OrderService")->first(["code"=>$item["订单编号"]]);
+                    if (!$order){
+                        $errors[] = "第“" . ($index + 2) . "”行已成功修改FLUX库位但在本地未找到订单";
+                        continue;
+                    }
+                    $barcode = app("CommodityBarcodeService")->first(["code"=>$item["商品条码"]]);
+                    if (!$barcode){
+                        $errors[] = "第“" . ($index + 2) . "”行已成功修改FLUX库位但在本地未找到条码";
+                        continue;
+                    }
+                    $model = app("OrderCommodityAssignService")->create([
+                        "order_id"      =>  1,//$order->id,
+                        "commodity_id"  =>  1,//$barcode->commodity_id,
+                        "amount"        =>  $item["数量"],
+                        "produced_at"   =>  $item["生产日期"],
+                        "valid_at"      =>  $item["失效日期"],
+                        "batch_number"  =>  $result->lotnum,
+                        "location"      =>  $result->locationid,
+                        "region"        =>  $result->pickzone,
+                        "user_id"       =>  Auth::id(),
+                    ]);
+                    LogService::log(__METHOD__,"SUCCESS-生成配置记录",json_encode($model));
+                    $ids[] = $model->id;
+                }catch (\Exception $e){
+                    LogService::log(__METHOD__,"ERROR-指定效期分配修改库位",json_encode($detail)." | ".json_encode($result));
+                }
+            }else $errors[] = "第“" . ($index + 2) . "”行未找到可分配库位";
+        }
+        $assigns = app("OrderCommodityAssignService")->get(["id"=>$ids]);
+        $models = [];
+        foreach ($assigns as $assign){
+            $models[] = [
+                "orderNumber"   => $assign->order ? $assign->order->code : '',
+                "barcode"       => $assign->commodity ? $assign->commodity->barcode : '',
+                "amount"        => $assign->amount,
+                "producedAt"    => $assign->produced_at,
+                "validAt"       => $assign->valid_at,
+                "batchNumber"   => $assign->batch_number,
+                "location"      => $assign->location,
+                "region"        => $assign->region,
+                "createdAt"     => $assign->created_at,
+                "userName"      => $assign->user ? $assign->user->name : 'system',
+            ];
+        }
+        Cache::put("commodityAssign",["success"=>true,"data"=>$models,"errors"=>$errors]);
+    }
+}

+ 44 - 0
app/Jobs/ProcessCreateInstantBill.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Process;
+use App\Services\LogService;
+use App\Services\ProcessService;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+class ProcessCreateInstantBill implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    protected $process;
+    /**
+     * Create a new job instance.
+     *
+     * @param Process $process
+     * @return void
+     */
+    public function __construct(Process $process)
+    {
+        $this->process = $process;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @param ProcessService $service
+     * @return void
+     */
+    public function handle(ProcessService $service)
+    {
+        try{
+            $service->createInstantBill($this->process);
+        }catch (\Exception $e){
+            LogService::log(__METHOD__,"ERROR-入库生成即时账单",$this->process->toJson()." | ".$e->getMessage());
+        }
+    }
+}

+ 45 - 0
app/Jobs/StoreCreateInstantBill.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Services\LogService;
+use App\Services\StoreService;
+use App\Store;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+class StoreCreateInstantBill implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+
+    protected $store;
+    /**
+     * Create a new job instance.
+     *
+     * @param Store $store
+     * @return void
+     */
+    public function __construct(Store $store)
+    {
+        $this->store = $store;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @param StoreService $service
+     * @return void
+     */
+    public function handle(StoreService $service)
+    {
+        try{
+            $service->createInstantBill($this->store);
+        }catch (\Exception $e){
+            LogService::log(__METHOD__,"ERROR-入库生成即时账单",$this->store->toJson()." | ".$e->getMessage());
+        }
+    }
+}

+ 7 - 0
app/Log.php

@@ -4,6 +4,7 @@ namespace App;
 
 use Illuminate\Database\Eloquent\Model;
 use App\Traits\ModelTimeFormat;
+use Illuminate\Support\Str;
 
 class Log extends Model
 {
@@ -19,4 +20,10 @@ class Log extends Model
         }
         return '';
     }
+    public function getExceptionMarkAttribute(){
+        if (Str::upper(substr($this->type,0,1)) != 'E')return 'N';
+        if (Str::upper(substr($this->type,0,5)) == 'ERROR' || Str::upper(substr($this->type,0,9)) == 'EXCEPTION')
+            return 'Y';
+        return 'N';
+    }
 }

+ 33 - 0
app/OrderCommodityAssign.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class OrderCommodityAssign extends Model
+{
+    protected $fillable = [
+        "order_id",         //外键订单
+        "commodity_id",     //外键商品
+        "amount",           //数量  default 0
+        "produced_at",      //生产日期
+        "valid_at",         //失效日期
+        "batch_number",     //批次号
+        "location",         //库位
+        "region",           //库区
+        "user_id",          //操作人
+    ];
+
+    public function order()
+    {   //订单
+        return $this->hasOne(Order::class,"id","order_id");
+    }
+    public function commodity()
+    {   //商品
+        return $this->hasOne(Commodity::class,"id","commodity_id");
+    }
+    public function user()
+    {   //用户
+        return $this->hasOne(User::class,"id","user_id");
+    }
+}

+ 2 - 2
app/Providers/AppServiceProvider.php

@@ -2,7 +2,6 @@
 
 namespace App\Providers;
 
-use App\Customer;
 use App\Http\Controllers\Controller;
 use App\Services\AuthorityService;
 use App\Services\CacheService;
@@ -23,8 +22,8 @@ use App\Services\OracleBasSkuService;
 use App\Services\OracleDocAsnDetailService;
 use App\Services\OracleDOCOrderHeaderService;
 use App\Services\OrderCommodityService;
+use App\Services\OrderCommodityAssignService;
 use App\Services\OrderCountingRecordService;
-use App\Services\OracleDocAsnHerderService;
 use App\Services\OrderIssuePerformanceService;
 use App\Services\AllInventoryService;
 use App\Services\InventoryDailyLogService;
@@ -173,6 +172,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('OwnerPriceExpressService',OwnerPriceExpressService::class);
         app()->singleton('OwnerPriceLogisticService',OwnerPriceLogisticService::class);
         app()->singleton('OwnerPriceDirectLogisticService',OwnerPriceDirectLogisticService::class);
+        app()->singleton('OrderCommodityAssignService',OrderCommodityAssignService::class);
 
         $this->loadingOrderModuleService();
         $this->loadingBasedModuleService();

+ 31 - 0
app/Services/OrderCommodityAssignService.php

@@ -0,0 +1,31 @@
+<?php 
+
+namespace App\Services; 
+
+use App\OrderCommodityAssign;
+
+Class OrderCommodityAssignService
+{ 
+
+    public function paginate(array $params = null)
+    {
+        $query = OrderCommodityAssign::query()->with(["order","commodity.barcodes","user"])->orderByDesc("id");
+        return $query->paginate($params["paginate"] ?? 50);
+    }
+
+    public function create(array $params)
+    {
+        return OrderCommodityAssign::query()->create($params);
+    }
+
+    public function get(array $params)
+    {
+        $query = OrderCommodityAssign::query()->with(["order","commodity.barcodes","user"]);
+        foreach ($params as $column=>$param){
+            if (is_array($param))$query->whereIn($column,$param);
+            else $query->where($column,$param);
+        }
+        return $query->get();
+    }
+
+}

+ 7 - 10
app/Services/OrderService.php

@@ -1148,13 +1148,7 @@ class OrderService
     {
         //检查订单对象
         if (!$order || $order->wms_status != "订单完成")return false;
-        if (!$order->packages || !$order->packages[0]->commodities || !$order->packages[0]->commodities[0]->commodity)$order->load(["packages"=>function($query){
-            /** @var Builder $query */
-            $query->with(["commodities"=>function($query){
-                /** @var Builder $query */
-                $query->with("commodity");
-            }]);
-        }]);
+        $order->loadMissing(["logistic","packages.commodities.commodity"]);
 
         /** @var OwnerPriceExpressService $service */
         $service = app("OwnerPriceExpressService");
@@ -1164,6 +1158,9 @@ class OrderService
         $volume = 0;
         $weight = 0;
         $logistic_bill = "";
+
+        if (!$order->logistic || $order->logistic->type != "快递")$logistic_fee = null;
+
         foreach ($order->packages as &$package){
             $logistic_bill .= $package->logistic_number.",";
             $volume += $package->bulk;
@@ -1192,8 +1189,8 @@ class OrderService
         }
         if ($logistic_fee!==null && $logistic_fee<0)$logistic_fee = null;
 
-        $object = ["commodities"=>$commodities,"logistic_name"=>($order->logistic ? $order->logistic->name : ''),"shop_name"=>($order->shop ? $order->shop->name : '')];
-        $mapping = ["packages"=>"commodities","商品名称"=>"commodity_name","承运商"=>"logistic_name","店铺类型"=>"shop_name"];
+        $object = ["commodities"=>$commodities,"logistic_name"=>($order->logistic ? $order->logistic->name : ''),"shop_name"=>($order->shop ? $order->shop->name : ''),"order_type"=>$order->order_type];
+        $mapping = ["packages"=>"commodities","商品名称"=>"commodity_name","承运商"=>"logistic_name","店铺类型"=>"shop_name","订单类型"=>"order_type"];
 
         /** @var OwnerPriceOperationService $service */
         $service = app("OwnerPriceOperationService");
@@ -1205,7 +1202,7 @@ class OrderService
             "worked_at"         => $order->wms_edittime,
             "type"              => "发货",
             "shop_id"           => $order->shop_id,
-            "operation_bill"    => $order->client_code,
+            "operation_bill"    => $order->code,
             "consignee_name"    => $order->consignee_name,
             "consignee_phone"   => $order->consignee_phone,
             "commodity_amount"  => $amount,

+ 15 - 0
app/Services/OwnerFeeDetailService.php

@@ -60,4 +60,19 @@ Class OwnerFeeDetailService
         return OwnerFeeDetail::query()->create($params);
     }
 
+    public function first(array $params)
+    {
+        $query = OwnerFeeDetail::query();
+        foreach ($params as $column=>$param){
+            if (is_array($param))$query->whereIn($column,$param);
+            else $query->where($column,$param);
+        }
+        return $query->first();
+    }
+
+    public function updateFind(OwnerFeeDetail $detail, array $values)
+    {
+        return $detail->update($values);
+    }
+
 }

+ 20 - 0
app/Services/ProcessService.php

@@ -94,4 +94,24 @@ Class ProcessService
                 ->selectRaw('sign_commodity_barcode.mark sign_commodity_barcode_mark')
             ->sql();
     }
+
+    public function createInstantBill(Process $process)
+    {
+        if (!$process || $process->status!="交接完成")return false;
+        if (!$process->processStatistic)$process->load("processStatistic");
+
+        if (app("OwnerFeeDetailService")->create([
+            "owner_id"          => $process->owner_id,
+            "worked_at"         => $process->processStatistic ? $process->processStatistic->ended_at : '',
+            "type"              => "增值服务",
+            "operation_bill"    => $process->code,
+            "commodity_amount"  => $process->completed_amount,
+            "process_method_id" => $process->process_method_id,
+            "work_fee"          => $process->processStatistic ? $process->processStatistic->revenue : null,
+            "created_at"        => date('Y-m-d H:i:s'),
+            "outer_id"          => $process->id,
+            "outer_table_name"  => "processes",
+        ]))return true;
+        return false;
+    }
 }

+ 28 - 0
app/Services/StoreService.php

@@ -183,4 +183,32 @@ Class StoreService
         $asn_nos = array_unique(data_get($asnHerders,'*.asnno'));
         return Store::query()->whereIn('asn_code',$asn_nos)->get();
     }
+
+    public function createInstantBill(Store $store):bool
+    {
+        if (!$store || $store->status!="已入库")return false;
+        if (!$store->storeItems)$store->load("storeItems");
+
+
+        /** @var OwnerPriceOperationService $service */
+        $service = app("OwnerPriceOperationService");
+
+        $mapping = ["packages"=>"storeItems","商品名称"=>"name","订单类型"=>"stored_method"];
+
+        $work_fee = $service->matchRule($store,$mapping,$store->owner_id,"入库");
+        if ($work_fee < 0)$work_fee = null;
+
+        if (app("OwnerFeeDetailService")->create([
+            "owner_id"          => $store->owner_id,
+            "worked_at"         => $store->created_at,
+            "type"              => "收货",
+            "operation_bill"    => $store->asn_code,
+            "commodity_amount"  => array_sum(array_column($store->storeItems->toArray(),"amount")),
+            "work_fee"          => $work_fee,
+            "created_at"        => date('Y-m-d H:i:s'),
+            "outer_id"          => $store->id,
+            "outer_table_name"  => "stores",
+        ]))return true;
+        return false;
+    }
 }

+ 43 - 0
app/Services/WaybillService.php

@@ -143,4 +143,47 @@ Class WaybillService
             ->selectRaw('logistics.name carrier_name')
             ->sql();
     }
+
+    public function createInstantBill(Waybill $waybill) :bool
+    {
+        if (!$waybill || $waybill->status != "已完结" || !$waybill->wms_bill_number || !$waybill->logistic_id)return false;
+        $waybill->loadMissing("destinationCity");
+        if (!$waybill->destinationCity)return false;
+
+        $detail = app("OwnerFeeDetailService")->first([
+            "type" => "发货","owner_id" => $waybill->owner_id,"operation_bill"=>$waybill->wms_bill_number
+        ]);
+        if (!$detail || $detail->logistic_fee !== null)return false;
+
+        if ($waybill->type == "专线"){
+            /** @var OwnerPriceLogisticService $service */
+            $service = app("OwnerPriceLogisticService");
+            $fee = $service->matching($waybill->carrier_weight_other,$waybill->owner_id,$waybill->logistic_id,
+                $waybill->carrier_weight_unit_id_other,$waybill->destinationCity->province_id,
+                $waybill->destination_city_id);
+        }else{
+            /** @var OwnerPriceDirectLogisticService $service */
+            $service = app("OwnerPriceDirectLogisticService");
+            $fee = $service->matching($waybill->mileage,$waybill->owner_id,$waybill->carType_id);
+        }
+
+        if ($fee >= 0){
+            app("OwnerFeeDetailService")->updateFind($detail,[
+                "owner_id" => $waybill->owner_id,
+                "worked_at"=> $waybill->updated_at,
+                "type" => "发货",
+                "operation_bill" => $waybill->waybill_number,
+                "consignee_name" => $waybill->recipient,
+                "consignee_phone" => $waybill->recipient_mobile,
+                "commodity_amount" => $waybill->amount,
+                "logistic_bill" => $waybill->carrier_bill,
+                "volume" =>$waybill->carrier_weight ?? $waybill->warehouse_weight,
+                "weight" => $waybill->carrier_weight_other ?? $waybill->warehouse_weight_other,
+                "logistic_id" => $waybill->logistic_id,
+                "logistic_fee" => $fee,
+                "outer_id" => $waybill->id,
+                "outer_table_name" => "waybills",
+            ]);
+        }
+    }
 }

+ 11 - 0
app/Utils/helpers.php

@@ -0,0 +1,11 @@
+<?php
+
+use Carbon\Carbon;
+
+function formatExcelDate(int $timestamp)
+{
+    $diff = intval($timestamp);
+    $today=new Carbon('1900-01-01');
+    $day = $today->addDays($diff-2);
+    return $day->toDateString();
+}

+ 3 - 0
composer.json

@@ -57,6 +57,9 @@
         "classmap": [
             "database/seeds",
             "database/factories"
+        ],
+        "files": [
+            "app/Utils/helpers.php"
         ]
     },
     "autoload-dev": {

+ 2 - 2
config/cache.php

@@ -9,9 +9,9 @@ return [
         'oftenChange'=>5,       //经常改
         'rarelyChange'=>60,     //几乎不变
         'commonFrequent'=>20,  //一般频率
+        'forever' =>null,       //永久
+
         'owners'=>20,           //模型Owner
-        'logistic'=>40,           //模型Logistic
-        'warehouse'=>60,           //模型WareHouse
     ],
     /*
     |--------------------------------------------------------------------------

+ 52 - 0
database/migrations/2020_12_02_150054_create_order_commodity_assigns_table.php

@@ -0,0 +1,52 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateOrderCommodityAssignsTable extends Migration
+{
+
+    protected $authorities = [
+        "商品配置",
+        "商品配置-查询",
+        "商品配置-编辑",
+    ];
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        foreach ($this->authorities as $val) \App\Authority::query()->firstOrCreate(["name"=>$val,"alias_name"=>$val]);
+
+        Schema::create('order_commodity_assigns', function (Blueprint $table) {
+            $table->id();
+            $table->bigInteger("order_id")->index()->comment("外键订单");
+            $table->bigInteger("commodity_id")->comment("外键商品");
+            $table->integer("amount")->default(0)->comment("数量");
+            $table->date("produced_at")->nullable()->comment("生产日期");
+            $table->date("valid_at")->nullable()->comment("失效日期");
+            $table->string("batch_number")->index()->nullable()->comment("批次号");
+            $table->string("location")->index()->nullable()->comment("库位");
+            $table->string("region")->index()->nullable()->comment("库区");
+            $table->bigInteger("user_id")->index()->nullable()->comment("操作人");
+            $table->timestamps();
+            $table->index(["commodity_id","produced_at"]);
+            $table->index(["commodity_id","valid_at"]);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('order_commodity_assigns');
+
+        foreach ($this->authorities as $val) \App\Authority::query()->where("name",$val)->where("alias_name",$val)->delete();
+    }
+}

+ 19 - 0
resources/views/maintenance/log/_taskModal.blade.php

@@ -0,0 +1,19 @@
+<div class="modal fade" tabindex="-1" role="dialog" id="task">
+    <div class="modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable">
+        <div class="modal-content">
+            <div class="modal-header">
+                <div class="container-fluid">
+                    <div class="row">
+
+                    </div>
+                </div>
+            </div>
+            <div class="modal-body">
+                <div v-html="detail"></div>
+            </div>
+            <div class="modal-footer">
+
+            </div>
+        </div>
+    </div>
+</div>

+ 6 - 4
resources/views/maintenance/log/index.blade.php

@@ -31,8 +31,8 @@
                         <th>ip</th>
                         <th>时间</th>
                     </tr>
-                    <tr v-for="log in logs" class="hover" @click="logsClick(log)" style="cursor: pointer">
-                        <td class="text-muted">@{{log.id}}</td>
+                    <tr v-for="log in logs" class="hover" @click="logsClick(log)" style="cursor: pointer;">
+                        <td class="text-muted">@{{log.id}}<span class="badge badge-danger small pull-right mr-3" v-if="log.mark == 'Y'">异常</span></td>
                         <td>@{{log.user_name}}</td>
                         <td>@{{log.operation}}</td>
                         <td>@{{log.type}}</td>
@@ -70,7 +70,8 @@
                         operation: '{{$log->operation}}',
                         type: '{{$log->type}}',
                         ip: '{{$log->ip}}',
-                        created_at: '{{$log->created_at}}'
+                        created_at: '{{$log->created_at}}',
+                        mark:'{{$log->exception_mark}}',
                     },
                     @endforeach
                     @endif
@@ -83,7 +84,8 @@
                         {name: 'type', type: 'input', tip: '操作', placeholder: '类型'},
                         {name: 'description', type: 'input', tip: '详情:可在两侧添加百分号(%)进行模糊搜索', placeholder: '详情'},
                         {name:'created_at_start',type:'dateTime',tip:'选择显示指定日期的起始时间'},
-                        {name:'created_at_end',type:'dateTime',tip:'选择显示指定日期的截止'}
+                        {name:'created_at_end',type:'dateTime',tip:'选择显示指定日期的截止'},
+                        {name:'is_exception',type:'checkbox',tip:'仅显示异常', data: [{name: 'true', value: '仅显示异常'}]}
                     ]
                 ];
                 this.from = new query({

+ 18 - 2
resources/views/maintenance/log/show.blade.php

@@ -10,7 +10,8 @@
             </li>
         @endcomponent
     </div>
-    <div class="container-fluid">
+    <div class="container-fluid" id="container">
+        {{--@include("maintenance.log._taskModal")--}}
         <div class="card ">
             <div class="card-body">
                 <table class="table table-striped">
@@ -32,7 +33,10 @@
                     </tr>
                     <tr>
                         <td>详细</td>
-                        <td style="word-break: break-all;">{{$log['description']}}</td>
+                        <td style="word-break: break-all;">
+                            {{--<button v-if="mark == 'Y'" class="btn btn-sm btn-success ml-2" data-toggle="modal" data-target="#task">重新分发</button>--}}
+                            <div {{--v-else--}} v-html="detail"></div>
+                        </td>
                     </tr>
                     <tr>
                         <td>用户</td>
@@ -47,3 +51,15 @@
         </div>
     </div>
 @endsection
+
+@section('lastScript')
+<script>
+    new Vue({
+        el:"#container",
+        data:{
+            mark:"{{$log['exception_mark']}}",
+            detail:"{{$log['description']}}".split('|'),
+        },
+    });
+</script>
+@stop

+ 25 - 0
resources/views/order/index/_importModal.blade.php

@@ -0,0 +1,25 @@
+<div class="modal fade" tabindex="-1" role="dialog" id="importModal">
+    <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
+        <div class="modal-content">
+            <div class="modal-body">
+                <div class="w-100 text-center mb-1" v-if="errors.length > 0">
+                    <button class="btn btn-sm btn-danger mb-1" @click="isShowError = true" v-if="!isShowError">@{{ errors.length }}条错误,点击展开</button>
+                    <button class="btn btn-sm btn-dark mb-1" @click="isShowError = false" v-else>收起错误展示</button>
+                    <div v-if="isShowError" class="container-fluid text-danger font-weight-bolder">
+                        <div class="row text-left">
+                            <div class="col-6" v-for="error in errors">@{{ error }}</div>
+                        </div>
+                    </div>
+                </div>
+                <div class="mt-5 mb-5">
+                    <input id="file" type="file" class="d-none" accept=".csv, .xlsx, .xls" @change="importAssign($event)"/>
+                    <label class="w-100 text-center small"><b>表头示例:</b><label class="text-primary">订单编号  商品条码  数量  生产日期  失效日期</label></label>
+                    <label class="w-100 row d-block ml-1"><input type="button" class="btn btn-dark col-6 offset-3" value="导入商品配置" @click="selectFile()"></label>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 125 - 0
resources/views/order/index/index.blade.php

@@ -0,0 +1,125 @@
+@extends('layouts.app')
+@section('title')订单管理-商品配置@endsection
+
+@section('content')
+    @component('order.index.menu')@endcomponent
+<div class="container-fluid d-none" id="container">
+    @include("order.index._importModal")
+    <div class="card">
+        <div class="card-body">
+            <button class="btn  btn-outline-info mb-1" data-toggle="modal" data-target="#importModal">导入</button>
+            <table class="table table-striped table-hover" id="headerParent">
+                <tr id="header"></tr>
+                <tr v-for="(model,i) in models">
+                    <td>@{{ i+1 }}</td>
+                    <td>@{{ model.orderNumber }}</td>
+                    <td>@{{ model.barcode }}</td>
+                    <td>@{{ model.amount }}</td>
+                    <td>@{{ model.producedAt }}</td>
+                    <td>@{{ model.validAt }}</td>
+                    <td>@{{ model.batchNumber }}</td>
+                    <td>@{{ model.location }}</td>
+                    <td>@{{ model.region }}</td>
+                    <td>@{{ model.createdAt }}</td>
+                    <td>@{{ model.userName }}</td>
+                </tr>
+            </table>
+        </div>
+    </div>
+    {{$assigns->links()}}
+</div>
+@endsection
+
+@section('lastScript')
+<script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>
+<script>
+    new Vue({
+        el:"#container",
+        data:{
+            models:[
+                @foreach($assigns as $assign)
+                {
+                    orderNumber:"{{$assign->order ? $assign->order->code : ''}}",
+                    barcode:"{{$assign->commodity ? $assign->commodity->barcode : ''}}",
+                    amount:"{{$assign->amount}}",
+                    producedAt:"{{$assign->produced_at}}",
+                    validAt:"{{$assign->valid_at}}",
+                    batchNumber:"{{$assign->batch_number}}",
+                    location:"{{$assign->location}}",
+                    region:"{{$assign->region}}",
+                    createdAt:"{{$assign->created_at}}",
+                    userName:"{{$assign->user ? $assign->user->name : 'system'}}",
+                },
+                @endforeach
+            ],
+            isShowError : false,
+            errors:[],
+        },
+        mounted(){
+            $("#container").removeClass("d-none");
+            let column = [
+                {name:'index',value: '序号', neglect: true},
+                {name:'orderNumber',value: '订单编号'},
+                {name:'barcode',value: '商品条码'},
+                {name:'amount',value: '数量', neglect: true},
+                {name:'producedAt',value: '生产日期'},
+                {name:'validAt',value: '失效日期'},
+                {name:'batchNumber',value: '批次号'},
+                {name:'location',value: '库位'},
+                {name:'region',value: '库区'},
+                {name:'createdAt',value: '导入日期'},
+                {name:'userName',value: '操作人'},
+            ];
+            let header = new Header({
+                el: "#header",
+                column: column,
+                data: this.models,
+                restorationColumn: 'id',
+            });
+            header.init();
+        },
+        methods:{
+            selectFile(){
+                $("#file").click();
+            },
+            importAssign(e){
+                let file=e.target.files[0];
+                if (!file){
+                    tempTip.setDuration(3000);
+                    tempTip.setIndex(1099);
+                    tempTip.show("未选择文件");
+                    return;
+                }
+                let formData = new FormData();
+                formData.append("file",file);
+                window.tempTip.setIndex(1099);
+                window.tempTip.setDuration(9999);
+                window.tempTip.waitingTip("执行中,请耐心等候......");
+                axios.post('{{url('order/index/commodityAssign/import')}}',formData,{
+                    'Content-Type':'multipart/form-data'
+                })
+                    .then(res=>{
+                        if (res.data.success) {
+                            if (res.data.data.length>0) {
+                                this.models.unshift.apply(this.models,res.data.data);
+                                if (this.models.length>50) this.models.split(50);
+                            }
+                            this.errors = res.data.errors;
+                            tempTip.cancelWaitingTip();
+                            tempTip.setDuration(2000);
+                            tempTip.showSuccess("导入成功!");
+                            return;
+                        }
+                        tempTip.cancelWaitingTip();
+                        tempTip.setDuration(3000);
+                        tempTip.show(res.data.data);
+                    }).catch(err=> {
+                    tempTip.cancelWaitingTip();
+                    tempTip.setDuration(3000);
+                    tempTip.show("网络错误:"+err);
+                })
+            }
+        },
+    });
+</script>
+@endsection

+ 4 - 0
resources/views/order/index/menu.blade.php

@@ -8,6 +8,10 @@
                     <li class="nav-item">
                         <a class="nav-link" href="{{url('order/index/delivering')}}" :class="{active:isActive('delivering',3)}">查询</a>
                     </li> @endcan
+                @can('商品配置')
+                    <li class="nav-item">
+                        <a class="nav-link" href="{{url('order/index/commodityAssign')}}" :class="{active:isActive('commodityAssign',3)}">商品配置</a>
+                    </li> @endcan
             </ul>
         </div>
     </div>

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

@@ -4,7 +4,7 @@
         <ul class="nav nav-pills">
             @can('订单管理-查询')
             <li class="nav-item">
-                <a class="nav-link" href="{{url('order/index/delivering')}}" :class="{active:isActive('delivering',3)}">订单</a>
+                <a class="nav-link" href="{{url('order/index/delivering')}}" :class="{active:isActive('index',2)}">订单</a>
             </li>
             @endcan
             @can('订单管理-波次-查询')

+ 50 - 30
resources/views/store/checkingReceive/show.blade.php

@@ -109,12 +109,12 @@
                     <td>@{{ storeCheckingReceiveItem.imported_amount }}</td>
                     <td @click="showInput(storeCheckingReceiveItem.id)" v-if="is_show">
                         <div class="form-inline">
-                            <input  @blur="delFocus()" :id = "'counted_amount_'+storeCheckingReceiveItem.id" :value="storeCheckingReceiveItem.counted_amount"
-                                    class="form-control form-control-sm" type="text" :disabled="disabledItemId == storeCheckingReceiveItem.id ? false : true">
+                            <input @focus="showInput(storeCheckingReceiveItem.id)"  @blur="delFocus()" :id = "'counted_amount_'+storeCheckingReceiveItem.id" :value="storeCheckingReceiveItem.counted_amount"
+                                    class="form-control form-control-sm" type="number" :disabled="disabledItemId == storeCheckingReceiveItem.id ? false : true">
                             <button v-if="disabledItemId == storeCheckingReceiveItem.id" type="button" class="btn btn-sm btn-success ml-1"
                                 @click="updateCountedAmount(storeCheckingReceiveItem)">确定</button>
                             <button v-if="disabledItemId == storeCheckingReceiveItem.id" type="button" class="btn btn-sm btn-danger"
-                                @click="disabledItemId = ''">取消</button>
+                                @click.stop="disabledItemId = ''">取消</button>
                         </div>
                     </td>
                     <td v-if="!is_show">@{{ storeCheckingReceiveItem.counted_amount }}</td>
@@ -125,19 +125,20 @@
                     <td>@{{ storeCheckingReceiveItem.invalid_at }}</td>
                     <td>@{{ storeCheckingReceiveItem.batch_code }}</td>
                     <td>@{{ storeCheckingReceiveItem.unique_code }}</td>
+                    <td>@can('入库管理-盘收一体-盘收-编辑')<button @click="destroyItem(storeCheckingReceiveItem,i)" class="btn btn-sm btn-outline-danger">删除</button>@endcan</td>
                 </tr>
             </table>
         </div>
         <!-- phone <544 -->
         <div class="d-xl-none">
             <div v-for="(storeCheckingReceiveItem,i) in storeCheckingReceiveItems" class="mt-1 border border-1 rounded"
-                 @click="openAll(storeCheckingReceiveItem.id)">
+                @click="openAll(storeCheckingReceiveItem.id)">
                 <div class="row">
                     <div class="col-6">
                         <label class="text-muted">序号:</label>@{{ i+1 }}
                     </div>
                     <div class="col-6">
-                        <span class="pull-right mr-1 text-muted font-weight-bold">···</span>
+                        <span class="pull-right mr-1 text-primary font-weight-bold small">点击展开</span>
                     </div>
                 </div>
                 <div class="row">
@@ -151,8 +152,8 @@
                     </div>
                 </div>
                 <div class="row">
-                    <div class="col-12">
-                        <label class="text-muted">名称:</label>@{{ storeCheckingReceiveItem.commodity_name }}
+                    <div class="col-12 form-inline">
+                        <label class="text-muted w-25">名称:</label><div class="w-75">@{{ storeCheckingReceiveItem.commodity_name }}</div>
                     </div>
                 </div>
                 <div class="row">
@@ -163,29 +164,21 @@
                         <label class="text-muted">实盘数:</label>@{{ storeCheckingReceiveItem.counted_amount }}
                     </div>
                 </div>
-                <div v-if="signOpenId == storeCheckingReceiveItem.id">
-                    <div class="row">
-                        <div class="col-6">
-                            <label class="text-muted">导入数:</label>@{{ storeCheckingReceiveItem.imported_amount }}
-                        </div>
-                        <div class="col-6">
-                            <label class="text-muted">ASN数:</label>@{{ storeCheckingReceiveItem.asn_amount }}
-                        </div>
+                <div class="row">
+                    <div class="col-6">
+                        <label class="text-muted">导入差异:</label><small class="text-danger font-weight-bold">@{{ storeCheckingReceiveItem.imported_diff_amount }}</small>
                     </div>
-                    <div class="row">
-                        <div class="col-6">
-                            <label class="text-muted">导入差异:</label>@{{ storeCheckingReceiveItem.imported_diff_amount }}
-                        </div>
-                        <div class="col-6">
-                            <label class="text-muted">ASN差异:</label>@{{ storeCheckingReceiveItem.asn_amount }}
-                        </div>
+                    <div class="col-6">
+                        <label class="text-muted">ASN差异:</label><small class="text-danger font-weight-bold">@{{ storeCheckingReceiveItem.asn_amount }}</small>
                     </div>
+                </div>
+                <div :id="'detail_'+storeCheckingReceiveItem.id" class="up">
                     <div class="row">
                         <div class="col-6">
-                            <label class="text-muted">导入差异:</label>@{{ storeCheckingReceiveItem.imported_amount }}
+                            <label class="text-muted">导入:</label>@{{ storeCheckingReceiveItem.imported_amount }}
                         </div>
                         <div class="col-6">
-                            <label class="text-muted">ASN差异:</label>@{{ storeCheckingReceiveItem.asn_diff_amount }}
+                            <label class="text-muted">ASN数:</label>@{{ storeCheckingReceiveItem.asn_amount }}
                         </div>
                     </div>
                     <div class="row">
@@ -204,6 +197,11 @@
                             <label class="text-muted">批次号码:</label>@{{ storeCheckingReceiveItem.batch_code }}
                         </div>
                     </div>
+                    <div class="row">
+                        <div class="col-10 offset-1">
+                            @can('入库管理-盘收一体-盘收-编辑')<button @click.stop="destroyItem(storeCheckingReceiveItem,i)" class="btn btn-sm btn-outline-danger w-100">删除</button>@endcan
+                        </div>
+                    </div>
                 </div>
             </div>
         </div>
@@ -224,7 +222,7 @@
                 @foreach($storeCheckingReceive->storeCheckingReceiveItems as $storeCheckingReceiveItem)
                 {id:'{{$storeCheckingReceiveItem->id}}',bin_number:'{{$storeCheckingReceiveItem->bin_number}}',
                 commodity_name:"{{$storeCheckingReceiveItem->commodity ? $storeCheckingReceiveItem->commodity->name : ''}}",
-                commodity_barcodes:{!! $storeCheckingReceiveItem->commodity ? ($storeCheckingReceiveItem->commodity->barcodes ? $storeCheckingReceiveItem->commodity->barcodes : []) : [] !!},
+                commodity_barcodes:{!! $storeCheckingReceiveItem->commodity ? ($storeCheckingReceiveItem->commodity->barcodes ? $storeCheckingReceiveItem->commodity->barcodes : json_encode([])) : json_encode([]) !!},
                 imported_amount:'{{$storeCheckingReceiveItem->imported_amount}}',counted_amount:'{{$storeCheckingReceiveItem->counted_amount}}',
                 asn_amount:'{{$storeCheckingReceiveItem->asn_amount}}',imported_diff_amount:'{{$storeCheckingReceiveItem->imported_diff_amount}}',
                 asn_diff_amount:'{{$storeCheckingReceiveItem->asn_diff_amount}}',produced_at:'{{$storeCheckingReceiveItem->produced_at}}',
@@ -253,10 +251,11 @@
             lastScannedBarcode : '',
             asn : '',
             is_show : {!! $is_show !!},
-            signOpenId : "",
             disabledItemId : "",
+            upId:"",
         },
         mounted(){
+            $(".up").slideUp();
             $('#container').removeClass('d-none');
             $(".tooltipTarget").tooltip({'trigger':'hover'});
             let column = [
@@ -273,6 +272,7 @@
                 {name:'invalid_at',value: '有效期'},
                 {name:'batch_code',value: '批次号'},
                 {name:'unique_code',value: '唯一码'},
+                {name:'operating',value: '操作', neglect: true},
             ];
             let header = new Header({
                 el: "#header",
@@ -286,8 +286,11 @@
         methods:{
             //显示该条全部信息
             openAll(id){
-                if (this.signOpenId === id ) this.signOpenId = "";
-                else this.signOpenId = id;
+                if (this.upId == id) {$("#detail_"+id).slideUp(); this.upId = ''}
+                else {
+                    this.upId = id;
+                    $("#detail_"+id).slideDown();
+                }
             },
             //获取焦点,取消全局监听
             showInput(id){
@@ -541,9 +544,7 @@
                     _this.inputting.bin_number = item.bin_number;
                     _this.commit(item, signIncreasing);
                 }else{
-                    //_this.status.binDisable=false;
                     _this.lastScannedBarcode = _this.inputting.barcode;
-                    //_this.inputting.bin_number = item.bin_number;
                     _this.focusOutDocument();
                     window.tempTip.setInputType('number');
                     window.tempTip.inputVal('该条码存在但无隔口号,请输入:', function (bin_number) {
@@ -699,6 +700,25 @@
                         window.tempTip.setDuration(3000);
                         window.tempTip.show("网络错误:"+err);
                     });
+            },
+            destroyItem(item,index){
+                let url = "{{url("store/checkingReceive/destroyItem")}}";
+                let param = {id:item.id};
+                window.tempTip.confirm("确定要删除商品“"+item.commodity_name+"”的盘点吗?",()=>{
+                    window.axios.post(url,param).then((res)=>{
+                        if (res.data.success){
+                            this.$delete(this.storeCheckingReceiveItems,index);
+                            window.tempTip.setDuration(2000);
+                            window.tempTip.showSuccess("删除成功");
+                            return;
+                        }
+                        window.tempTip.setDuration(3000);
+                        window.tempTip.show(res.data.data);
+                    }).catch(err=>{
+                        window.tempTip.setDuration(3000);
+                        window.tempTip.show("网络错误:"+err);
+                    })
+                });
             }
         },
     });

+ 9 - 0
routes/web.php

@@ -159,6 +159,9 @@ Route::group(['prefix'=>'maintenance'],function(){
     Route::group(['prefix'=>'carType'],function (){
         Route::post('get','CarTypesController@get');
     });
+    Route::group(['prefix'=>"log"],function (){
+        Route::get("exception",'LogController@exception');
+    });
 
     Route::get('syncRedisLogs','LogController@syncRedisLogs');
     Route::resource('log', 'LogController');
@@ -328,6 +331,7 @@ Route::group(['prefix'=>'store'],function(){
         Route::post('updateCountedAmount','StoreCheckingReceiveController@updateCountedAmount');
         Route::post('insertItem','StoreCheckingReceiveController@insertItem');
         Route::get('mission','StoreCheckingReceiveController@mission');
+        Route::post('destroyItem','StoreCheckingReceiveController@destroyItem');
     });
 });
 
@@ -498,7 +502,12 @@ Route::group(['prefix'=>'order'],function(){
     /** 主页 */
     Route::group(['prefix'=>'index'],function(){
         Route::get('delivering','OrderController@delivering');
+        Route::get('commodityAssign','OrderCommodityAssignController@index');
         Route::match(['get','post'],'export','OrderController@export');
+
+        Route::group(['prefix'=>'commodityAssign'],function(){
+            Route::post('import','OrderCommodityAssignController@import');
+        });
     });
     /** 创建 */
     Route::group(['prefix'=>'create'],function(){