Jelajahi Sumber

Merge branch 'zzd' of ssh://was.baoshi56.com:10022/var/git/bswas

LD 5 tahun lalu
induk
melakukan
1896bb0cc3

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

@@ -171,17 +171,8 @@ sql;
 
     public function zzd()
     {
-        $item = [
-            "订单编号" => "SO210120009746",
-            "商品条码" => "3046920028004",
-        ];
-        $detail = OracleDOCOrderDetail::query()->select("DOC_ORDER_DETAILS.customerid","DOC_ORDER_DETAILS.sku","DOC_ORDER_DETAILS.orderno","DOC_ORDER_DETAILS.orderlineno","sostatus")
-            ->where("DOC_ORDER_DETAILS.orderno",$item["订单编号"])
-            ->whereHas("sku",function ($query)use($item){
-                /** @var Builder $query */
-                $query->where("alternate_sku1",$item["商品条码"]);
-            })->leftJoin("DOC_ORDER_HEADER","DOC_ORDER_DETAILS.ORDERNO","=","DOC_ORDER_HEADER.ORDERNO")->first();
-        dd($detail);
+        return app("RegionService")->getCity("哈达克力扣州");
+
     }
 
     public function mergeCarrier()

+ 2 - 0
app/Providers/AppServiceProvider.php

@@ -78,6 +78,7 @@ use App\Services\WarehouseService;
 use App\Services\WaybillFinancialService;
 use App\Services\WeighExceptedService;
 use App\Services\OrderFreezeService;
+use App\Services\RegionService;
 use Illuminate\Queue\Events\JobFailed;
 use Illuminate\Support\Facades\Queue;
 use Illuminate\Support\Facades\Schema;
@@ -185,6 +186,7 @@ class AppServiceProvider extends ServiceProvider
         app()->singleton('ProcessStatisticService',ProcessStatisticService::class);
         app()->singleton('ProcessesContentService',ProcessesContentService::class);
         app()->singleton('RealtimePendingOrdersService',RealtimePendingOrdersService::class);
+        app()->singleton('RegionService',RegionService::class);
         app()->singleton('RejectedBillItemService',RejectedBillItemService::class);
         app()->singleton('RejectedBillService',RejectedBillService::class);
         app()->singleton('RejectedService',RejectedService::class);

+ 16 - 6
app/Services/OwnerPriceOperationService.php

@@ -256,13 +256,23 @@ Class OwnerPriceOperationService
                     if ($isIn)break;
                     if ($unitName && $unitName != $units[$rule->unit_id])return -3; //校验单位是否一致
 
-                    $money = $rule->amount * $rule->unit_price;
-                    $startNumber = $rule->amount;
-                    $packages = $this->settingCount($packages,$amountColumn,$startNumber);
-                    if ($packages){
-                        foreach ($packages as $package){
-                            $money += $package[$amountColumn] * $package["price"];
+                    if ($rule->amount){ //起步数+起步费
+                        $money = $rule->unit_price;
+                        $startNumber = $rule->amount;
+                        $packages = $this->settingCount($packages,$amountColumn,$startNumber);
+                        if ($packages){
+                            foreach ($packages as $package){
+                                $money += $package[$amountColumn] * $package["price"];
+                            }
+                        }
+                    }else{//单起步费
+                        $money = 0;
+                        if ($packages){
+                            foreach ($packages as $package){
+                                $money += $package[$amountColumn] * $package["price"];
+                            }
                         }
+                        if ($money<$rule->unit_price)$money = $rule->unit_price;
                     }
                     return $money;
             }

+ 106 - 0
app/Services/RegionService.php

@@ -0,0 +1,106 @@
+<?php 
+
+namespace App\Services;
+
+use App\Region;
+use App\Traits\ServiceAppAop;
+
+class RegionService
+{
+    use ServiceAppAop;
+
+    /**
+     * 根据省份获取ID
+     *
+     * @param string $province
+     *
+     * @return int
+     */
+    public function getProvince(string $province):int
+    {
+        $pool = ["省","自治区","市","特别行政"];
+        $province = $this->extractKeyword($province,$pool);
+        $region = Region::withTrashed()->where("name","like",$province."%")
+            ->where("type",1)->first();
+        if (!$region)$region = Region::query()->create([
+            "name"      => $province,
+            "type"      => 2,
+        ]);
+        return $region->id;
+    }
+
+    /**
+     * 根据城市获取ID
+     *
+     * @param string $city
+     * @param string|int|null $parent
+     *
+     * @return int
+     */
+    public function getCity(string $city, $parent = null):int
+    {
+        $pool = ["市","区","自治州","州","盟"];
+        $city = $this->extractKeyword($city,$pool);
+        $region = Region::withTrashed()->where("name","like",$city."%")
+            ->where("type",2)->first();
+        if (!$region){
+            $region = [
+                "name"      => $city,
+                "type"      => 2,
+            ];
+            if ($parent){
+                if (is_int($parent))$region["parent_id"] = $parent;
+                else $region["parent_id"] = $this->getProvince($parent);
+            }
+            $region = Region::query()->create($region);
+        }
+        return $region->id;
+    }
+
+    /**
+     * 根据区县获取ID
+     *
+     * @param string $district
+     * @param string|int|null $parent
+     *
+     * @return int
+     */
+    public function getDistrict(string $district, $parent = null):int
+    {
+        $pool = ["市","区","自治县","县","自治旗","旗","特区","林区"];
+        $district = $this->extractKeyword($district,$pool);
+        $region = Region::withTrashed()->where("name","like",$district."%")
+            ->where("type",3)->first();
+        if (!$region){
+            $region = [
+                "name"      => $district,
+                "type"      => 3,
+            ];
+            if ($parent){
+                if (is_int($parent))$region["parent_id"] = $parent;
+                else $region["parent_id"] = $this->getCity($parent);
+            }
+            $region = Region::query()->create($region);
+        }
+        return $region->id;
+    }
+
+    /**
+     * 根据字典池提取关键字
+     *
+     * @param string $name
+     * @param array $pool
+     *
+     * @return string
+     */
+    private function extractKeyword(string $name,array $pool)
+    {
+        foreach ($pool as $keyword){
+            $result = mb_strpos($name,$keyword);
+            if ($result!==false){
+                return mb_substr($name,0,$result);
+            }
+        }
+        return $name;
+    }
+}

+ 7 - 0
app/Services/WaybillService.php

@@ -82,6 +82,13 @@ Class WaybillService
         return DB::transaction(function ()use($request){
             $waybill=new Waybill();
             $inputs = $request->all();
+            if ($inputs["wms_bill_number"]){
+                $order = app("OrderService")->first(["code"=>$inputs["wms_bill_number"]]);
+                if ($order){
+                    $inputs["destination_city_id"] = app("RegionService")->getCity($order->city,$order->province);
+                    $inputs["district_id"] = app("RegionService")->getDistrict($order->district,$order->city);
+                }
+            }
             $inputs['status']='未审核';
             $inputs['waybill_number']=Uuid::uuid1();
             $waybill->fill($inputs);

+ 6 - 1
app/Waybill.php

@@ -21,9 +21,14 @@ class Waybill extends Model
         'status','type','waybill_number','owner_id','wms_bill_number','origination','destination','recipient','recipient_mobile','charge','ordering_remark',
         'logistic_id','carrier_bill','origination_city_id','destination_city_id','warehouse_weight','warehouse_weight_unit_id','carrier_weight','carrier_weight_unit_id','carType_id',
         'car_owner_info','fee','pick_up_fee','other_fee','collect_fee','dispatch_remark','waybill_price_model_id','warehouse_weight_other','warehouse_weight_unit_id_other'
-        ,'carrier_weight_other','carrier_weight_unit_id_other','source_bill','mileage','amount','inquire_tel','amount_unit_id','other_charge','other_charge_remark','deliver_at'
+        ,'carrier_weight_other','carrier_weight_unit_id_other','source_bill','mileage','amount','inquire_tel','amount_unit_id','other_charge','other_charge_remark','deliver_at',
+        "district_id"
     ];
 
+    public function district()
+    {   //区
+        return $this->belongsTo(Region::class,"district_id","id")->where("type",3);
+    }
     public function owner(){
         return $this->hasOne('App\Owner','id','owner_id');
     }

+ 19 - 0
database/migrations/2021_01_20_104314_add_column_deleted_at_table_region.php

@@ -6,6 +6,13 @@ use Illuminate\Support\Facades\Schema;
 
 class AddColumnDeletedAtTableRegion extends Migration
 {
+    protected $name = [
+        "地域",
+        "地域-查询",
+        "地域-录入",
+        "地域-编辑",
+        "地域-删除",
+    ];
     /**
      * Run the migrations.
      *
@@ -15,7 +22,15 @@ class AddColumnDeletedAtTableRegion extends Migration
     {
         Schema::table('regions', function (Blueprint $table) {
             $table->softDeletes();
+            $table->index("type");
         });
+
+        foreach ($this->name as $name){
+            \App\Authority::query()->firstOrCreate([
+                "name"=>$name,
+                "alias_name"=>$name
+            ]);
+        }
     }
 
     /**
@@ -27,6 +42,10 @@ class AddColumnDeletedAtTableRegion extends Migration
     {
         Schema::table('regions', function (Blueprint $table) {
             $table->dropSoftDeletes();
+            $table->dropIndex(["type"]);
         });
+        foreach ($this->name as $name){
+            \App\Authority::query()->where("name",$name)->delete();
+        }
     }
 }

+ 32 - 0
database/migrations/2021_01_20_165449_add_column_district_id_table_waybills.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddColumnDistrictIdTableWaybills extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('waybills', function (Blueprint $table) {
+            $table->bigInteger("district_id")->nullable()->index()->comment("外键区");
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('waybills', function (Blueprint $table) {
+            $table->dropColumn("district_id");
+        });
+    }
+}

+ 3 - 3
resources/views/customer/project/create.blade.php

@@ -442,7 +442,7 @@
                     });
                 },
                 //加载仓储所需基础信息
-                async _loadStorage(){
+                _loadStorage(){
                     if (!this.pool.units)this._getUnits();
                     if (!this.isLoad && this.ownerTemp.id)this._loadPriceModel();//计费模型未被加载且项目ID存在时
                     if (!this.isLoad && !this.ownerTemp.id) this.isLoad = true;
@@ -636,10 +636,10 @@
                 _verifyOperationItem(itemIndex){//验证作业费子项信息完整
                     let obj = this.model.operation.items[itemIndex];
                     let sign = false;
-                    if (!obj.amount){
+                    if (obj.strategy!=='起步' && !obj.amount){
                         this.errors['items.'+itemIndex+'.amount'] = ["数量不得为空"];
                         sign = true;
-                    }
+                    }else if (!obj.amount) obj.amount = 0;
                     if (!obj.unit_id){
                         this.errors['items.'+itemIndex+'.unit_id'] = ["必须选择单位"];
                         sign = true;

+ 1 - 1
resources/views/customer/project/part/_express.blade.php

@@ -27,7 +27,7 @@
         <div class="w-100 form-inline">
             <input id="expressFile" type="file" class="d-none" accept=".csv, .xlsx, .xls" @change="importExpress($event)"/>
             <button type="button" class="btn btn-sm btn-outline-info w-25" @click="addExpressItem()">新增</button>
-            <button type="button" class="btn btn-sm btn-outline-primary w-25 ml-2" @click="   ('expressFile')" @mouseenter="hoverEffect('express',true)" @mouseleave="hoverEffect('express',false)">导入</button>
+            <button type="button" class="btn btn-sm btn-outline-primary w-25 ml-2" @click="selectFile('expressFile')" @mouseenter="hoverEffect('express',true)" @mouseleave="hoverEffect('express',false)">导入</button>
             <h5><span class="ml-0 fa fa-question-circle-o cursor-pointer" data-toggle="tooltip" data-placement="top" title="导入与保存时自动过滤重复数据"></span></h5>
         </div>
         <div class="w-100 mt-1 ml-1" v-if="model.express.items.length>searchBase">

+ 26 - 23
resources/views/customer/project/part/_operation.blade.php

@@ -35,13 +35,12 @@
 <div class="row mt-3">
     {{--起步--}}
     <div class="card row text-white offset-1 col-9 bg-dark" v-if="model.operation.operation_type === '出库'">
-        <div class="card-body">
+        <div class="card-header" style="max-height: 50px">
             <div class="row">
-                <label class="col-3">子策略:</label>
-                <label class="col-5"><select disabled v-model="model.operation.items[0].strategy" class="form-control">
-                    <option value="起步">起步</option>
-                </select></label>
+                <div class="col-6 offset-3 text-center">起&nbsp;&nbsp;&nbsp;&nbsp;步</div>
             </div>
+        </div>
+        <div class="card-body">
             <div class="row mt-2">
                 <label class="col-3">起步数</label>
                 <label class="col-5 mb-0"><input id="amount" type="number" :class="errors['items.0.amount'] ? 'is-invalid' : ''"
@@ -60,7 +59,7 @@
                 <div class="offset-3"><small class="text-danger font-weight-bold ml-3">单位为必选项</small></div>
             </div>
             <div class="row mt-2">
-                <label class="col-3">单价</label>
+                <label class="col-3">起步费</label>
                 <label class="col-5 mb-0"><input type="number" min="0" step="0.001" class="form-control" v-model="model.operation.items[0].unit_price"
                            :class="errors['items.0.unit_price'] ? 'is-invalid' : ''"></label>
             </div>
@@ -72,16 +71,17 @@
 
     {{--默认--}}
     <div class="card row text-white offset-1 col-9 bg-info">
-        <div class="card-header">
-            <div class="pull-left cursor-pointer text-white" @click="addOperationItem()"><small>新增</small>&nbsp;<span class="fa fa-plus-square-o"></span></div>
-        </div>
-        <div class="card-body">
+        <div class="card-header" style="max-height: 50px">
             <div class="row">
-                <label class="col-3">子策略:</label>
-                <label class="col-5"><select disabled v-model="model.operation.items[1].strategy" class=" form-control">
-                    <option value="默认">默认</option>
-                </select></label>
+                <div class="col-3">
+                    <div class="pull-left cursor-pointer text-white" @click="addOperationItem()"><small>新增</small>&nbsp;<span class="fa fa-plus-square-o"></span></div>
+                </div>
+                <div class="col-6 text-center">
+                    默&nbsp;&nbsp;&nbsp;&nbsp;认
+                </div>
             </div>
+        </div>
+        <div class="card-body">
             <div class="row mt-2">
                 <label class="col-3">数量</label>
                 <label class="col-5 mb-0"><input id="amount" type="number" :class="errors['items.1.amount'] ? 'is-invalid' : ''"
@@ -114,17 +114,20 @@
 
     {{--特征--}}
     <div v-for="(item,i) in model.operation.items" class="card row text-white offset-1 col-9 bg-secondary" v-if="i>1">
-        <div class="card-header">
-            <div class="pull-left cursor-pointer text-white" @click="addOperationItem()"><small>新增</small>&nbsp;<span class="fa fa-plus-square-o"></span></div>
-            <div class="pull-right cursor-pointer text-white" @click="delOperationItem(i)"><small>删除</small>&nbsp;<span class="fa fa-window-close-o"></span></div>
-        </div>
-        <div class="card-body">
+        <div class="card-header" style="max-height: 50px">
             <div class="row">
-                <label class="col-3">子策略</label>
-                <label class="col-5"><select disabled v-model="item.strategy" class="form-control">
-                    <option value="特征">特征</option>
-                </select></label>
+                <div class="col-3">
+                    <div class="pull-left cursor-pointer text-white" @click="addOperationItem()"><small>新增</small>&nbsp;<span class="fa fa-plus-square-o"></span></div>
+                </div>
+                <div class="col-6 text-center">
+                    特&nbsp;&nbsp;&nbsp;&nbsp;征
+                </div>
+                <div class="col-3">
+                    <div class="pull-right cursor-pointer text-white" @click="delOperationItem(i)"><small>删除</small>&nbsp;<span class="fa fa-window-close-o"></span></div>
+                </div>
             </div>
+        </div>
+        <div class="card-body">
             <div class="row mt-2">
                 <label class="col-3">数量</label>
                 <label class="col-5 mb-0"><input type="number" step="1" min="0" :class="errors['items.'+i+'.amount'] ? 'is-invalid' : ''" v-model="item.amount" class="form-control"></label>

+ 1 - 1
tests/Services/OwnerPriceOperationService/OwnerPriceOperationServiceTest.php

@@ -167,7 +167,7 @@ class OwnerPriceOperationServiceTest extends  TestCase
         $result = $this->service->matching(["packages"=>[["commodity"=>"测试","amount"=>55,"sku"=>$this->data["commodities"][0]["sku"]]]],[],$this->data["owners"][0]["id"],"入库");
         $this->assertEquals(96.9,$result);
         $result = $this->service->matching(["packages"=>[["commodity"=>"测试","amount"=>57,"sku"=>$this->data["commodities"][0]["sku"]]]],[],$this->data["owners"][0]["id"],"出库");
-        $this->assertEquals(107.1,$result);
+        $this->assertEquals(79.60000000000001,$result);
     }
 
     public function tearDown(): void