Forráskód Böngészése

账单生成与一些行为方式
炬星接口(部分)

Zhouzhendong 4 éve
szülő
commit
a5c0454dab
29 módosított fájl, 461 hozzáadás és 130 törlés
  1. 1 32
      app/Console/Commands/CreateOwnerBillReport.php
  2. 44 17
      app/Http/Controllers/CustomerController.php
  3. 2 2
      app/Http/Controllers/PriceModelController.php
  4. 11 5
      app/Http/Controllers/TestController.php
  5. 36 0
      app/Http/Controllers/api/thirdPart/syrius/beans/StorageTypeAttribute.php
  6. 22 0
      app/Http/Controllers/api/thirdPart/syrius/beans/StorageTypeCell.php
  7. 21 0
      app/Http/Controllers/api/thirdPart/syrius/beans/StorageTypeRelation.php
  8. 31 0
      app/Http/Controllers/api/thirdPart/syrius/beans/Task.php
  9. 20 0
      app/Http/Controllers/api/thirdPart/syrius/consumer/OrderController.php
  10. 46 3
      app/Http/Controllers/api/thirdPart/syrius/producer/BinLocation.php
  11. 10 7
      app/Http/Controllers/api/thirdPart/syrius/producer/Controller.php
  12. 24 0
      app/Http/Controllers/api/thirdPart/syrius/producer/OrderController.php
  13. 46 0
      app/Http/Controllers/api/thirdPart/syrius/producer/StorageTypeController.php
  14. 25 0
      app/Http/Controllers/api/thirdPart/syrius/units/Signature.php
  15. 4 3
      app/Jobs/ResetInstantBill.php
  16. 3 0
      app/Providers/RouteServiceProvider.php
  17. 3 2
      app/Services/ForeignHaiRoboticsService.php
  18. 24 17
      app/Services/OrderService.php
  19. 32 0
      app/Services/OwnerAreaReportService.php
  20. 3 2
      app/Services/OwnerPriceExpressService.php
  21. 4 3
      app/Services/OwnerPriceOperationService.php
  22. 2 1
      app/Services/OwnerStoragePriceModelService.php
  23. 16 12
      app/Services/StoreService.php
  24. 7 7
      config/api.php
  25. 12 12
      resources/views/customer/project/create.blade.php
  26. 3 3
      resources/views/customer/project/part/_three.blade.php
  27. 1 1
      resources/views/maintenance/role/index.blade.php
  28. 7 0
      routes/api/thirdPart/syrius.php
  29. 1 1
      routes/web.php

+ 1 - 32
app/Console/Commands/CreateOwnerBillReport.php

@@ -6,7 +6,6 @@ use App\OwnerAreaReport;
 use App\OwnerFeeStorage;
 use App\OwnerPriceSystem;
 use App\Services\LogService;
-use Carbon\Carbon;
 use Illuminate\Console\Command;
 use Illuminate\Support\Facades\DB;
 
@@ -78,7 +77,7 @@ class CreateOwnerBillReport extends Command
             OwnerFeeStorage::query()->create($GLOBALS["FEE_INFO"]);
         }
         foreach (OwnerPriceSystem::query()->with(["timeUnit","taxRate"])->select("owner_id","usage_fee")->whereNull("operation")->orWhere("operation","")->get() as $system){
-            list($systemFee[$system->owner_id],$systemTaxFee[$system->owner_id]) = $this->systemFee($system,$year."-".$lastMonth);
+            list($systemFee[$system->owner_id],$systemTaxFee[$system->owner_id]) = app("OwnerAreaReportService")->systemFee($system,$year."-".$lastMonth);
         }
         $chunks = array_chunk($billDetails,50);
         foreach ($chunks as $bills){
@@ -102,34 +101,4 @@ class CreateOwnerBillReport extends Command
             DB::table("owner_bill_reports")->insert($createOwnerBillReport);
         }
     }
-
-    /**
-     * 系统费用
-     *
-     * @param OwnerPriceSystem|\stdClass $system
-     * @param string $month
-     *
-     * @return array
-     */
-    private function systemFee(OwnerPriceSystem $system,$month)
-    {
-        if (!$system->timeUnit)$money = $system->usage_fee;
-        else{
-            switch ($system->timeUnit->name){
-                case "日":
-                    $money = $system->usage_fee*(Carbon::parse($month)->lastOfMonth()->format("d"));
-                    break;
-                case "单":
-                    $money = $system->usage_fee * (app("OrderService")->getOrderQuantity($system->owner_id));
-                    break;
-                case "年":
-                    $money = $system->usage_fee/12;
-                    break;
-                default:
-                    $money = $system->usage_fee;
-            }
-        }
-        $taxFee = app("OwnerService")->getTaxRateFee($system, $system->owner_id, $money);
-        return array($money,$taxFee);
-    }
 }

+ 44 - 17
app/Http/Controllers/CustomerController.php

@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
 use App\Components\AsyncResponse;
 use App\Jobs\OrderCreateInstantBill;
 use App\Jobs\ResetInstantBill;
+use App\Jobs\SettlementBillReportJob;
 use App\Jobs\StoreCreateInstantBill;
 use App\Order;
 use App\Owner;
@@ -15,6 +16,8 @@ use App\OwnerFeeExpress;
 use App\OwnerFeeLogistic;
 use App\OwnerFeeOperation;
 use App\OwnerFeeOperationDetail;
+use App\OwnerFeeStorage;
+use App\OwnerPriceSystem;
 use App\OwnerReport;
 use App\Services\LogService;
 use App\Services\OwnerAreaReportService;
@@ -577,10 +580,12 @@ class CustomerController extends Controller
     public function resetBillConfirmation()
     {
         $month = request("month");
+        if (!$month)$this->error("无日期");
         $owner = request("owner");
+        if ($owner && !is_array($owner))$this->error("非法数据");
         $sql = <<<sql
-SELECT owner_id,SUM(IFNULL(work_fee,0)) AS work_fee,SUM(IFNULL(logistic_fee,0)) AS logistic_fee
-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))
+SELECT owner_id,SUM(IFNULL(work_fee,0)) AS work_fee,SUM(IFNULL(logistic_fee,0)) AS logistic_fee 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))
 sql;
         if ($owner && count($owner)>0){
             $sql.=" AND owner_id IN (''";
@@ -590,34 +595,56 @@ sql;
         $sql .= " GROUP BY owner_id";
 
         $billDetails = DB::select(DB::raw($sql),[$month."%"]);
-
-        $areas = OwnerAreaReport::query()->with(["ownerStoragePriceModel.timeUnit","ownerStoragePriceModel.taxRate"])->where("counting_month","like",$month."%")->get();
+        $areas = OwnerAreaReport::query()->with(["ownerStoragePriceModel.timeUnit","ownerStoragePriceModel.taxRate"])
+            ->where("counting_month","like",$month."%");
+        if ($owner && count($owner)>0){
+            $areas->whereIn("owner_id",$owner);
+        }
+        $areas = $areas->get();
         $map = [];
         $mapTax = [];
         foreach($areas as $area){
+            if (!$area->ownerStoragePriceModel)continue;
+            //信息提取模板
+            $GLOBALS["FEE_INFO"] = [
+                "counting_type"     =>$area->ownerStoragePriceModel->counting_type,
+                "using_type"        =>$area->ownerStoragePriceModel->using_type,
+                "fee_description"   =>"",
+                "total_fee"         =>0,
+                "tax_rate"          =>0,
+            ];
             $key = $area->owner_id."_".$area->counting_month;
-            if (isset($map[$key])){
-                if (!$area->ownerStoragePriceModel)continue;
-                list($money,$taxFee) = app('OwnerStoragePriceModelService')
-                    ->calculationAmount($area->ownerStoragePriceModel,$area->accounting_area,$area->owner_id,$area->counting_month);
-                $map[$key] += $money;
-                $mapTax[$key] += $taxFee;
-            }else{
-                if (!$area->ownerStoragePriceModel)continue;
-                list($map[$key],$mapTax[$key]) = app('OwnerStoragePriceModelService')
-                    ->calculationAmount($area->ownerStoragePriceModel,$area->accounting_area,$area->owner_id,$area->counting_month);
-            }
+            if (!isset($map[$key]))$map[$key] = $mapTax[$key] = 0;
+            list($money,$taxFee) = app('OwnerStoragePriceModelService')
+                ->calculationAmount($area->ownerStoragePriceModel,$area->accounting_area,$area->owner_id,$area->counting_month);
+            $map[$key] += $money;
+            $mapTax[$key] += $taxFee;
+
+            $GLOBALS["FEE_INFO"]["total_fee"] = $money;
+            OwnerFeeStorage::query()->where("area_id",$area->id)
+                ->update($GLOBALS["FEE_INFO"]);
+        }
+        foreach (OwnerPriceSystem::query()->with(["timeUnit","taxRate"])
+                     ->select("owner_id","usage_fee")->whereNull("operation")
+                     ->orWhere("operation","")->get() as $system){
+            list($systemFee[$system->owner_id],$systemTaxFee[$system->owner_id]) =
+                app("OwnerAreaReportService")->systemFee($system,$month);
         }
-
         $chunks = array_chunk($billDetails,50);
         foreach ($chunks as $bills){
             foreach ($bills as $bill){
                 $key = $bill->owner_id."_".$month;
                 OwnerBillReport::query()->where("owner_id",$bill->owner_id)
                     ->where("counting_month",$month."-01")
-                    ->update(["work_fee"=>$bill->work_fee,"logistic_fee"=>$bill->logistic_fee,"storage_fee"=>$map[$key] ?? 0,"storage_tax_fee"   => $mapTax[$key] ?? 0]);
+                    ->update(["work_fee"=>$bill->work_fee,
+                        "logistic_fee"=>$bill->logistic_fee,
+                        "storage_fee"=>$map[$key] ?? 0,
+                        "other_fee"         => $systemFee[$bill->owner_id] ?? null,
+                        "other_tax_fee"     => $systemTaxFee[$bill->owner_id] ?? null,
+                        "storage_tax_fee"   => $mapTax[$key] ?? 0]);
             }
         }
+        $this->dispatch(new SettlementBillReportJob($month."-01",$owner));
         $this->success();
     }
 }

+ 2 - 2
app/Http/Controllers/PriceModelController.php

@@ -1242,8 +1242,8 @@ class PriceModelController extends Controller
                 foreach ($params["items"] as $item){
                     $obj = [
                         "province_id"               => $item["province_id"],
-                        "initial_weight_price"      => $item["initial_weight_price"],
-                        "additional_weight_price"   => $item["additional_weight_price"],
+                        "initial_weight_price"      => json_encode($item["initial_weight_price"]),
+                        "additional_weight_price"   => json_encode($item["additional_weight_price"]),
                     ];
                     if (isset($item["id"])){
                         $obj["id"] = $item["id"];

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

@@ -12,6 +12,7 @@ use App\Components\ErrorPush;
 use App\ErrorTemp;
 use App\Feature;
 use App\Http\ApiControllers\LoginController;
+use App\Http\Controllers\api\thirdPart\syrius\units\StorageTypeAttribute;
 use App\Http\Requests\AndroidGateRequest;
 use App\Http\Requests\OrderDelivering;
 use App\Jobs\BatchTaskJob;
@@ -201,13 +202,18 @@ class TestController extends \App\Http\Controllers\api\thirdPart\syrius\producer
         }
         app("BatchService")->assignTasks($batches);
     }
+    public function test1()
+    {
+        dd(1);
+    }
     public function test()
     {
-        dd(app("MenuService")->getVisibleFunctionList());
-        dd($this->response("德玛西亚",[]));
-       $st = '[{"taskMode":1,"bins":[{"taskCode":"102876_1632099648.1379","binCode":"IDE0000686","fromLocCode":"BIN-IN1","toLocCode":""}],"groupCode":"_1632099648.1379","priority":10,"sequenceFlag":1}]';
-       $st = json_decode($st,true);
-       $st[0]["sequenceFlag"] = 0;
+        dd(substr("2021-01-20 00:00",0,7));
+        $a = new StorageTypeAttribute();
+        $a->openingDirection = 1;
+        $a->toolType = 1;
+        $a->icon = "1";
+        dd((array)$a->get());
        dd(json_encode($st));
        $order = Order::query()->find(4367620);
        $s = new OrderService();

+ 36 - 0
app/Http/Controllers/api/thirdPart/syrius/beans/StorageTypeAttribute.php

@@ -0,0 +1,36 @@
+<?php
+
+
+namespace App\Http\Controllers\api\thirdPart\syrius\beans;
+
+
+class StorageTypeAttribute
+{
+    const OPENING_DIRECTION = [
+        "BACK","TOP","SIDE"
+    ];
+    const TOOL_TYPE = [
+        "standard","shoe_box","clothes_hanger"
+    ];
+    public string $icon;          //图片路径
+    public int $quantity;      //数量
+    public float $length;        //长度
+    public float $width;         //宽度
+    public float $high;          //高度
+    //Optional
+    public $openingDirection;        //开启方向
+    public float $weight;        //图片路径
+    public $toolType;      //工具类型
+    public float $maxLoad;       //存储最大负载
+    //Optional
+    public float $number;        //存储单元数
+    public int $layers;        //层数
+    public int $numOfLayerCell;//层单元数
+
+    public function get():StorageTypeAttribute
+    {
+        $this->openingDirection = self::OPENING_DIRECTION[$this->openingDirection];
+        $this->toolType = self::TOOL_TYPE[$this->toolType];
+        return $this;
+    }
+}

+ 22 - 0
app/Http/Controllers/api/thirdPart/syrius/beans/StorageTypeCell.php

@@ -0,0 +1,22 @@
+<?php
+
+
+namespace App\Http\Controllers\api\thirdPart\syrius\beans;
+
+
+class StorageTypeCell
+{
+    public string $name;    //名称
+    public string $color;   //颜色
+    //Optional
+    public bool $disassemble;//是否拆分
+    public int $capacity;   //容量
+    public float $length;   //长度
+    public float $width;    //宽度
+    public float $high;     //高度
+
+    public function get():StorageTypeCell
+    {
+        return $this;
+    }
+}

+ 21 - 0
app/Http/Controllers/api/thirdPart/syrius/beans/StorageTypeRelation.php

@@ -0,0 +1,21 @@
+<?php
+
+
+namespace App\Http\Controllers\api\thirdPart\syrius\beans;
+
+
+class StorageTypeRelation
+{
+    //Optional
+    public string $storageTypeId;   //类型ID
+    public bool $require;           //是否必须
+    //Optional
+    public int $num;                //号码
+    //Optional
+    public string $relationExpression;//关系表达式
+
+    public function get():StorageTypeRelation
+    {
+        return $this;
+    }
+}

+ 31 - 0
app/Http/Controllers/api/thirdPart/syrius/beans/Task.php

@@ -0,0 +1,31 @@
+<?php
+
+
+namespace App\Http\Controllers\api\thirdPart\syrius\beans;
+
+
+class Task
+{
+    const ORDER_PICKING = "ORDER_PICKING";
+    const TOTAL_PICKING = "TOTAL_PICKING";
+    const PUTAWAY = "PUTAWAY";
+    public string $id;                      //任务ID
+    //Optional
+    public string $batchId;                 //批次ID
+    //ENUM
+    public string $type;                    //任务类型
+    //Optional:between(1,10) default:5
+    public string $priority;                //优先级
+    public string $timestamp;               //下达时间
+    //Optional
+    public string $expectedExecutionTime;   //预计执行时间
+    //Optional
+    public string $expectedFinishTime;      //预计完成时间
+    public string $warehouseId;             //仓库ID
+    //Optional
+    public string $notifyUrl;               //任务执行通知地址
+
+    public array $storages;                 //存储Storage对象示例:[{type:"",serialNo:""}]
+    public $attributes;                     //一些属性:{dischargeLocations:""},这里在初始传递时应为一个对象,通过内部转换为key-val数组
+    public array $items;
+}

+ 20 - 0
app/Http/Controllers/api/thirdPart/syrius/consumer/OrderController.php

@@ -0,0 +1,20 @@
+<?php
+
+
+namespace App\Http\Controllers\api\thirdPart\syrius\consumer;
+
+
+use App\Http\Controllers\api\thirdPart\syrius\units\Signature;
+use Illuminate\Http\Request;
+
+class OrderController
+{
+    use Signature;
+
+    public function receiptNotification(Request $request)
+    {
+        //TODO 需要在这里补充验签与返回
+        return response("OK")
+            ->header("Content-Type","application/json");
+    }
+}

+ 46 - 3
app/Http/Controllers/api/thirdPart/syrius/producer/BinLocation.php

@@ -6,6 +6,8 @@ namespace App\Http\Controllers\api\thirdPart\syrius\producer;
 class BinLocation extends Controller
 {
     /**
+     * 建立新库位
+     *
      * @param string $locationId
      * @param \stdClass $warehouse  {id:"",name:""}
      * @param \stdClass $attribute  {id:"",layer:0,num:0}
@@ -13,8 +15,9 @@ class BinLocation extends Controller
      */
     public function createBinLocation(string $locationId, \stdClass $warehouse, \stdClass $attribute)
     {
-        $url = config("api.syrius.request.bin_location");
-        $body = [[
+        $this->method = "post";
+        $this->url = config("api.syrius.request.bin_location");
+        $this->data = [[
             "binLocationId"     => $locationId,     //库位ID
             "warehouseId"       => $warehouse->id,  //仓库ID
             "warehouseName"     => $warehouse->name,//仓库名
@@ -24,6 +27,46 @@ class BinLocation extends Controller
                 "numOfLayer" => $attribute->num,    //架层数
             ],
         ]];
-        $this->response($url,$body);
+        $this->response();
+    }
+
+    /**
+     * 获取库位
+     *
+     * @param string|array $locationId
+     * @param string $warehouseId
+     * @param int $page
+     * @param int $paginate
+     */
+    public function getBinLocation($locationId, string $warehouseId, int $page = 0, int $paginate= 1)
+    {
+        if (!is_array($locationId))$locationId = [$locationId];
+        $this->method = "get";
+        $this->url = config("api.syrius.request.find_all_bin_location");
+        $this->data = [
+            "pageIndex" => $page,              //页数
+            "pageSize"  => $paginate,          //行数
+            "warehouseId"=> $warehouseId,      //仓库ID
+            "binLocationIds"=> $locationId,    //库位ID数组
+        ];
+        $this->response();
+    }
+
+    /**
+     * 删除库位
+     *
+     * @param string|array $locationId
+     * @param string $warehouseId
+     */
+    public function delBinLocation($locationId, string $warehouseId)
+    {
+        if (!is_array($locationId))$locationId = [$locationId];
+        $this->method = "delete";
+        $this->url = config("api.syrius.request.delete_bin_location");
+        $this->data = [
+            "warehouseId" => $warehouseId,
+            "binLocationIds" => $locationId
+        ];
+        $this->response();
     }
 }

+ 10 - 7
app/Http/Controllers/api/thirdPart/syrius/producer/Controller.php

@@ -12,20 +12,23 @@ use Illuminate\Support\Facades\Log;
 
 class Controller
 {
-    public function response($url, $data): ?Response
+    protected string $method;
+    protected string $url;
+    protected array $data = [];
+    public function response(): ?Response
     {
+        $url = config("api.syrius.base_url").$this->url;
         $logInfo = [
-            "param" =>  $data,
+            "param" =>  $this->data,
             "user"  =>  Auth::id(),
             "ip"    =>  request()->ip(),
         ];
-
         $token = "";
         try {
-            return Http::withHeaders([
-                'Accept' => 'application/json',
-                'Authorization' => 'Bearer '.$token,
-            ])->post($url,$data);
+            $method = $this->method;
+            $headers = ['Authorization' => 'Bearer '.$token];
+            if ($method=='post')$headers["Content-Type"] = 'application/json';
+            return Http::withHeaders($headers)->$method($url,$this->data);
         }catch (ConnectionException $e){
             Log::warning("syrius:连接异常",$logInfo);
         }catch (\Exception $e){

+ 24 - 0
app/Http/Controllers/api/thirdPart/syrius/producer/OrderController.php

@@ -0,0 +1,24 @@
+<?php
+
+
+namespace App\Http\Controllers\api\thirdPart\syrius\producer;
+
+
+use App\Http\Controllers\api\thirdPart\syrius\beans\Task;
+
+class OrderController extends Controller
+{
+    public function createOrder(Task $order)
+    {
+        $this->method = "post";
+        $this->url = config("api.syrius.request.create_order");
+        $this->response();
+    }
+
+    public function getOrder(string $id)
+    {
+        $this->method = "get";
+        $this->url = config("api.syrius.request.find_order").$id;
+        $this->response();
+    }
+}

+ 46 - 0
app/Http/Controllers/api/thirdPart/syrius/producer/StorageTypeController.php

@@ -0,0 +1,46 @@
+<?php
+
+
+namespace App\Http\Controllers\api\thirdPart\syrius\producer;
+
+
+use App\Http\Controllers\api\thirdPart\syrius\beans\StorageTypeAttribute;
+
+class StorageTypeController extends Controller
+{
+    /**
+     * 创建存储类型
+     *
+     * @param string $name
+     * @param string $tagName
+     * @param StorageTypeAttribute $attributes
+     * @param array $cells [StorageTypeCell]
+     * @param array $relations [StorageTypeRelation]
+     */
+    public function createStorageType(string $name, string $tagName,
+           StorageTypeAttribute $attributes, array $cells, array $relations)
+    {
+        $this->method = "post";
+        $this->url = config("api.syrius.request.create_storage_type");
+        $this->data = [
+            "name" => $name,
+            "tagName" => $tagName,
+            "attributes" => (array)$attributes,
+            "cells" => $cells,
+            "relations" => $relations,
+        ];
+        $this->response();
+    }
+
+    /**
+     * 获取存储类型
+     *
+     * @param string $storageId
+     */
+    public function getStorageType(string $storageId)
+    {
+        $this->method = "get";
+        $this->url = config("api.syrius.request.find_storage_type").$storageId;
+        $this->response();
+    }
+}

+ 25 - 0
app/Http/Controllers/api/thirdPart/syrius/units/Signature.php

@@ -0,0 +1,25 @@
+<?php
+
+
+namespace App\Http\Controllers\api\thirdPart\syrius\units;
+
+
+trait Signature
+{
+    public function verify(string $requestUrl, string $waitSignBody):bool
+    {
+        $secret = config("api.syrius.client_secret");
+        $baseUrl = config("app.url");
+        $arr = explode("&signature=",$requestUrl);
+        if (count($arr)!=2)return false;
+        $signature = $arr[1];
+        $waitSignUrl = ltrim($arr[0],$baseUrl);
+        $plainText = "POST"."\n".$waitSignUrl."\n".$waitSignBody."\n";
+        return $signature == $this->sign($secret.":".$plainText);
+    }
+
+    public function sign(string $str):string
+    {
+        return hash("sha256",$str);
+    }
+}

+ 4 - 3
app/Jobs/ResetInstantBill.php

@@ -53,12 +53,13 @@ class ResetInstantBill implements ShouldQueue
                 //加载所需数据
                 $order->loadMissing(["logistic","shop","packages.commodities.commodity","batch"]);
                 //获取运输费
-                $logisticInfo = app("OrderService")->getLogisticFeeInfo($order);
+                $month = substr($this->detail->worked_at,0,7);
+                $logisticInfo = app("OrderService")->getLogisticFeeInfo($order,$month);
                 //获取作业费
                 /** @var OwnerPriceOperationService $service */
                 $service = app("OwnerPriceOperationService");
                 $GLOBALS["FEE_INFO"] = [];
-                list($id,$money,$workTaxFee) = $service->matching($order,Feature::MAPPING["order"],$order->owner_id);
+                list($id,$money,$workTaxFee) = $service->matching($month, $order,Feature::MAPPING["order"],$order->owner_id);
                 //数据组装
                 OwnerFeeDetail::query()->where("id",$this->detail->id)->update([
                     "commodity_amount"  => $logisticInfo["amount"],
@@ -150,7 +151,7 @@ class ResetInstantBill implements ShouldQueue
                 list($id,$money,$taxFee) = $service->matching($store, Feature::MAPPING["store"], $store->owner_id, "入库");
                 $amount = 0;
                 if ($store->storeItems)foreach ($store->storeItems as $item)$amount += $item->amount;
-                if (($this->detail->commodity_amount - $amount)!==0)app("StoreService")->setStoreAmount($store->owner_id,$this->detail->commodity_amount - $amount);
+                if (($this->detail->commodity_amount - $amount)!==0)app("StoreService")->setStoreAmount($store->owner_id,$this->detail->commodity_amount - $amount,substr($this->detail->worked_at,0,7));
                 $this->detail->update([
                     "commodity_amount" => $amount,
                     "work_fee" => $money,

+ 3 - 0
app/Providers/RouteServiceProvider.php

@@ -117,5 +117,8 @@ class RouteServiceProvider extends ServiceProvider
             ->middleware('api')
             ->namespace('App\Http\Controllers\api\thirdPart\haochuang')
             ->group(base_path('routes/api/thirdPart/haochuang.php'));
+        Route::prefix("api/thirdPart/syrius")
+            ->namespace('App\Http\Controllers\api\thirdPart\syrius\consumer')
+            ->group(base_path('routes/api/thirdPart/syrius.php'));
     }
 }

+ 3 - 2
app/Services/ForeignHaiRoboticsService.php

@@ -403,11 +403,12 @@ class ForeignHaiRoboticsService
 
     /**
      * @param array $dataToPost
+     * @param Collection $taskMaterialBoxes
+     * @param string|null $modeName
      * @return bool
      */
-    public function controlHaiRobot(array $dataToPost,Collection $taskMaterialBoxes,$modeName): bool
+    public function controlHaiRobot(array $dataToPost,Collection $taskMaterialBoxes, string $modeName): bool
     {
-        $dataToPost[0]["sequenceFlag"] = 0; //TODO 关闭组内有序
         LogService::log('海柔请求','runMany','波次任务分配6.r5f2c1:'.json_encode($dataToPost));
         try{
             LogService::log('海柔请求','runMany','波次任务分配6.r5f2c1.51:');

+ 24 - 17
app/Services/OrderService.php

@@ -1100,25 +1100,27 @@ class OrderService
      *
      * @param int $owner
      * @param array|null $logistics
+     * @param string|null $month
      */
-    private function orderQuantityCompensationLogic($owner, $logistics = null)
+    private function orderQuantityCompensationLogic(int $owner, ?array $logistics = null, ?string $month = null)
     {
         if (!$logistics) $logistics = app("OwnerPriceExpressService")->getBuildLogistic($owner);
+        if (!$month)$month = date("Y-m");
         $query = DB::raw(<<<sql
 SELECT COUNT(1) count,logistic_id FROM orders WHERE wms_status = '订单完成'
 AND owner_id = ?
 AND wms_edittime like ? GROUP BY logistic_id
 sql
         );
-        $statistics = DB::select($query, [$owner, date("Y-m") . "%"]);
+        $statistics = DB::select($query, [$owner, $month . "%"]);
         $toB = 0;
         $toC = 0;
         foreach ($statistics as $statistic) {
             if (array_search($statistic->logistic_id, $logistics) === false) $toB += $statistic->count;
             else $toC += $statistic->count;
         }
-        Cache::put(date("Y-m") . "|B|" . $owner, $toB, 2764800);
-        Cache::put(date("Y-m") . "|C|" . $owner, $toC, 2764800);
+        Cache::put($month . "|B|" . $owner, $toB, 2764800);
+        Cache::put($month . "|C|" . $owner, $toC, 2764800);
     }
 
     /**
@@ -1126,17 +1128,18 @@ sql
      *
      * @param int|null $owner
      * @param int|null $logistic
+     * @param string|null $month
      */
-    public function setOrderQuantity(?int $owner, ?int $logistic)
+    public function setOrderQuantity(?int $owner, ?int $logistic, ?string $month = null)
     {
         if (!$owner || !$logistic) return;
         $logistics = app("OwnerPriceExpressService")->getBuildLogistic($owner);
-        $date = date("Y-m");
+        $date = $month ?: date("Y-m");
         if (array_search($logistic, $logistics) === false) $type = "|B|";
         else $type = "|C|";
         if (!Cache::has($date . $type . $owner)) {
             //补偿逻辑
-            $this->orderQuantityCompensationLogic($owner, $logistics);
+            $this->orderQuantityCompensationLogic($owner, $logistics, $month);
         }
         Cache::increment($date . $type . $owner);
         $key = $date . "|D|" . $owner;
@@ -1154,12 +1157,13 @@ sql
      *
      * @param int $owner
      * @param bool $isToB
+     * @param string|null $month
      *
      * @return int
      */
-    public function getOrderQuantity(int $owner, bool $isToB = false): int
+    public function getOrderQuantity(int $owner, bool $isToB = false, ?string $month = null): int
     {
-        $date = date("Y-m");
+        $date = $month ?: date("Y-m");
         if ($isToB) $type = "|B|";
         else $type = "|C|";
         if (!Cache::has($date . $type . $owner)) $this->orderQuantityCompensationLogic($owner);
@@ -1170,10 +1174,11 @@ sql
      * 获取物流费用信息
      *
      * @param Order|\stdClass $order
+     * @param string $month
      *
      * @return array
      */
-    public function getLogisticFeeInfo(Order $order): array
+    public function getLogisticFeeInfo(Order $order,string $month): array
     {
         //预定义返回参数
         $default = function () {
@@ -1192,12 +1197,12 @@ sql
         $unit = app("UnitService")->getUnit();
         $city = app("CityService")->getCity($order->city);
         $isBunched = $order->logistic->is_bunched == 'Y';
-        $exe = function ($type, $ownerId, $logisticId, $amount, $weight) use ($province, $unit, $city) {
+        $exe = function ($type, $ownerId, $logisticId, $amount, $weight) use ($province, $unit, $city, $month) {
             switch ($type) {
                 case "快递":
                     /** @var OwnerPriceExpressService $service */
                     $service = app("OwnerPriceExpressService");
-                    return $service->matching($weight, $ownerId, $logisticId, $province->id);
+                    return $service->matching($weight, $ownerId, $logisticId, $province->id, $month);
                 default:
                     /** @var OwnerPriceLogisticService $service */
                     $service = app("OwnerPriceLogisticService");
@@ -1279,19 +1284,21 @@ sql
         if (Cache::has("owner_fee_details:orders_" . $order->id)) return true;
         //加载所需数据
         $order->loadMissing(["logistic", "shop", "packages.commodities.commodity", "batch"]);
+        $workedAt = $order->wms_edittime ?: $order->updated_at;
         //获取运输费
-        $logisticInfo = $this->getLogisticFeeInfo($order);
+        $month = substr($workedAt,0,7);
+        $logisticInfo = $this->getLogisticFeeInfo($order,$month);
 
         //获取作业费
         /** @var OwnerPriceOperationService $service */
         $service = app("OwnerPriceOperationService");
         $GLOBALS["FEE_INFO"] = [];
-        list($id, $money, $workTaxFee) = $service->matching($order, Feature::MAPPING["order"], $order->owner_id);
+        list($id, $money, $workTaxFee) = $service->matching($month, $order, Feature::MAPPING["order"], $order->owner_id);
 
         //数据组装
         $detail = OwnerFeeDetail::query()->create([
             "owner_id" => $order->owner_id,
-            "worked_at" => $order->wms_edittime ?: $order->updated_at,
+            "worked_at" => $workedAt,
             "type" => "发货",
             "shop_id" => $order->shop_id,
             "operation_bill" => $order->code,
@@ -1328,7 +1335,7 @@ sql
         //后续处理
         foreach ($logisticInfo["items"] as &$item) $item["owner_fee_detail_id"] = $detail->id;
         if (count($logisticInfo["items"]) > 1) OwnerFeeDetailLogistic::query()->insert($logisticInfo["items"]);
-        $this->setOrderQuantity($order->owner_id, $order->logistic_id);
+        $this->setOrderQuantity($order->owner_id, $order->logistic_id, $month);
         Cache::put("owner_fee_details:orders_" . $order->id, 1, 86400);
         return true;
     }
@@ -1425,7 +1432,7 @@ sql
         $order->loadMissing(["logistic", "shop", "packages.commodities.commodity", "batch"]);
         if (!$order->packages->count() || !$order->owner) return false;
         //获取运输费
-        $logisticInfo = $this->getLogisticFeeInfo($order);
+        $logisticInfo = $this->getLogisticFeeInfo($order,substr($feeBill->worked_at,0,7));
         if (!$logisticInfo["logisticFee"] || !$logisticInfo["fee_info"]) return false;
         //获取作业费
         $GLOBALS["FEE_INFO"] = [];

+ 32 - 0
app/Services/OwnerAreaReportService.php

@@ -4,7 +4,9 @@ namespace App\Services;
 
 use App\OwnerAreaReport;
 use App\OwnerBillReport;
+use App\OwnerPriceSystem;
 use App\Services\common\QueryService;
+use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
@@ -128,4 +130,34 @@ class OwnerAreaReportService
             LogService::log(__METHOD__,"项目管理-生成盘点记录",json_encode($createOwnerAreaReport));
         }
     }
+
+    /**
+     * 系统费用
+     *
+     * @param OwnerPriceSystem|\stdClass $system
+     * @param string $month
+     *
+     * @return array
+     */
+    public function systemFee(OwnerPriceSystem $system,string $month):array
+    {
+        if (!$system->timeUnit)$money = $system->usage_fee;
+        else{
+            switch ($system->timeUnit->name){
+                case "日":
+                    $money = $system->usage_fee*(Carbon::parse($month)->lastOfMonth()->format("d"));
+                    break;
+                case "单":
+                    $money = $system->usage_fee * (app("OrderService")->getOrderQuantity($system->owner_id,false,$month));
+                    break;
+                case "年":
+                    $money = $system->usage_fee/12;
+                    break;
+                default:
+                    $money = $system->usage_fee;
+            }
+        }
+        $taxFee = app("OwnerService")->getTaxRateFee($system, $system->owner_id, $money);
+        return array($money,$taxFee);
+    }
 }

+ 3 - 2
app/Services/OwnerPriceExpressService.php

@@ -259,10 +259,11 @@ sql
      * @param integer $ownerId
      * @param integer $logisticId
      * @param integer $provinceId
+     * @param string $month
      *
      * @return array
      */
-    public function matching(float $weight, int $ownerId, int $logisticId, int $provinceId):array
+    public function matching(float $weight, int $ownerId, int $logisticId, int $provinceId, string $month):array
     {
         if (!$weight)return array(null,null);
 
@@ -271,7 +272,7 @@ sql
 
         $to1 = $to2 = 0;
         if ($model->amount_interval){
-            $total = app("OrderService")->getOrderQuantity($ownerId)+1;//获取该货主月C端单量
+            $total = app("OrderService")->getOrderQuantity($ownerId,false,$month)+1;//获取该货主月C端单量
             for ($i=count($model->amount_interval);$i<0;$i--)if ($total>=$model->amount_interval[$i]){$to1 = $i;break;}
             if (isset($to1) && isset($model->weight_interval[$to1])){
                 for ($i=count($model->weight_interval[$to1]);$i<0;$i--){

+ 4 - 3
app/Services/OwnerPriceOperationService.php

@@ -285,6 +285,7 @@ class OwnerPriceOperationService
      *
      *  2:没有总数量存在,都为子项内数量
      *
+     * @param string $month
      * @param array|object|Model $matchObject  key-val
      * @param array $columnMapping       key-val
      * @param integer $ownerId
@@ -314,14 +315,14 @@ class OwnerPriceOperationService
      * 十. 2021-08-13
      *      优化匹配模型,设置超全局费用信息提取
      */
-    public function matching($matchObject, array $columnMapping, int $ownerId, string $type = '出库', ?int $typeMark = null):array
+    public function matching(string $month, $matchObject, array $columnMapping, int $ownerId, string $type = '出库', ?int $typeMark = null):array
     {
         $units = app("UnitService")->getUnitMapping(["件","单","箱","m³","T","kg"],true); //获取单位映射集
         $rules = $this->getOwnerPriceOperation($ownerId,$type,$typeMark);//货主下的全部规则
         if (!$rules)return array(null,null,null);  //规则不存在跳出
 
         if ($type == '出库'){
-            $total = app("OrderService")->getOrderQuantity($ownerId)+1;//获取该货主本月C端单量
+            $total = app("OrderService")->getOrderQuantity($ownerId,false,$month)+1;//获取该货主本月C端单量
             $matchObject->packages->each(function ($package)use(&$orderTotal){
                 if($package->commodities->count()==0)return;
                 $package->commodities[0]->bulk = $package->bulk/1000000;
@@ -335,7 +336,7 @@ class OwnerPriceOperationService
             $total = 0;
             if ($matchObject->storeItems)foreach ($matchObject->storeItems as $item)$total += $item->amount;
             $matchObject[$columnMapping[12]] = $total;
-            $total += app("StoreService")->getStoreAmount($ownerId);//获取该货主本月入库件数
+            $total += app("StoreService")->getStoreAmount($ownerId,$month);//获取该货主本月入库件数
         }
         foreach ($rules as $rule){
             if (!$rule->items)continue; //不存在子规则跳出

+ 2 - 1
app/Services/OwnerStoragePriceModelService.php

@@ -107,6 +107,7 @@ class OwnerStoragePriceModelService
     //暂时不考虑单位换算问题:后期可能存在多单位换算,此处仅视为单位为 m²,m³
     public function calculationAmount(OwnerStoragePriceModel $model, $area, $owner_id = null, $month = null):array
     {
+        if (!$month)$month = date("Y-m");
         /** @var \stdClass $model */
         if (!$model || !$area || $model->operation) return array(0,null);
         if ($area < $model->minimum_area) $area = $model->minimum_area;
@@ -160,7 +161,7 @@ class OwnerStoragePriceModelService
         }
         $index = 0;
         if ($model->amount_interval){
-            $total = app("OrderService")->getOrderQuantity($owner_id);
+            $total = app("OrderService")->getOrderQuantity($owner_id,false,$month);
             for ($i=count($model->amount_interval)-1;$i>=0;$i--){
                 if ($total>=$model->amount_interval[$i])$index = $i;
             }

+ 16 - 12
app/Services/StoreService.php

@@ -316,18 +316,20 @@ class StoreService
         if (!$store || $store->status != "已入库") return false;
         if (Cache::has("owner_fee_details:stores_".$store->id))return true;
         $store->loadMissing(["storeItems.commodity","warehouse"]);
-
         /** @var OwnerPriceOperationService $service */
         $service = app("OwnerPriceOperationService");
 
+        $workedAt = $store->updated_at;
+        $month = substr($workedAt,0,7);
+
         $GLOBALS["FEE_INFO"] = [];
-        list($id,$money,$taxFee) = $service->matching($store, Feature::MAPPING["store"], $store->owner_id, "入库");
+        list($id,$money,$taxFee) = $service->matching($month, $store, Feature::MAPPING["store"], $store->owner_id, "入库");
 
         $amount = 0;
         if ($store->storeItems)foreach ($store->storeItems as $item)$amount += $item->amount;
         if (!app("OwnerFeeDetailService")->create([
             "owner_id" => $store->owner_id,
-            "worked_at" => $store->updated_at,
+            "worked_at" => $workedAt,
             "type" => "收货",
             "operation_bill" => $store->asn_code,
             "commodity_amount" => $amount,
@@ -338,9 +340,9 @@ class StoreService
             "outer_table_name" => "stores",
             "work_tax_fee" => $taxFee,
         ])) return false;
-        $this->setStoreAmount($store->owner_id,$amount);
+        $this->setStoreAmount($store->owner_id,$amount,$month);
         if ($money>0)$this->constructFeeInfo([
-            "worked_at" => $store->updated_at,
+            "worked_at" => $workedAt,
             "owner_id" => $store->owner_id,
             "model_id"  => $id,
             "source_number"=> null,
@@ -426,15 +428,16 @@ class StoreService
      * 入库件数丢失补偿逻辑
      *
      * @param int $owner
+     * @param string $month
      */
-    private function storeAmountCompensationLogic($owner)
+    private function storeAmountCompensationLogic(int $owner, string $month)
     {
         $query = DB::raw(<<<sql
 SELECT sum(amount) total FROM `store_items` LEFT JOIN stores ON store_items.store_id=stores.id WHERE stores.owner_id = ? AND (stores.status='已入库' OR stores.status='ASN关闭') AND store_items.updated_at LIKE ?
 sql
         );
         $statistics = DB::selectOne($query,[$owner,date("Y-m")."%"]);
-        Cache::put(date("Y-m")."|A|".$owner,$statistics->total ?: 0,2764800);
+        Cache::put($month."|A|".$owner,$statistics->total ?: 0,2764800);
     }
 
     /**
@@ -442,11 +445,12 @@ sql
      *
      * @param int $owner
      * @param int $amount
+     * @param string $month
      */
-    public function setStoreAmount($owner, $amount)
+    public function setStoreAmount(int $owner, int $amount, string $month)
     {
         $date = date("Y-m");
-        if (!Cache::has($date."|A|".$owner))$this->storeAmountCompensationLogic($owner);//补偿逻辑
+        if (!Cache::has($date."|A|".$owner))$this->storeAmountCompensationLogic($owner,$month);//补偿逻辑
         Cache::increment($date."|A|".$owner,$amount);
     }
 
@@ -454,13 +458,13 @@ sql
      * 获取货主下的本月入库件数
      *
      * @param int $owner
+     * @param string $date
      *
      * @return int
      */
-    public function getStoreAmount($owner)
+    public function getStoreAmount(int $owner, string $date):int
     {
-        $date = date("Y-m");
-        if (!Cache::has($date."|A|".$owner))$this->storeAmountCompensationLogic($owner);
+        if (!Cache::has($date."|A|".$owner))$this->storeAmountCompensationLogic($owner,$date);
         return Cache::get($date."|A|".$owner);
     }
 }

+ 7 - 7
config/api.php

@@ -64,13 +64,13 @@ return [
         "client_secret" => "vthuec06c1jrjr31nt98l8r7kune0uqdgrjeifm0472re923c15",
         "base_url"      => "",
         "request"       => [
-            "bin_location"  => "/account/binlocation/",         //POST
-            "find_all_bin_location" => " /account/binlocation/",//GET
-            "delete_bin_location" => " /account/binlocation/",  //DELETE
-            "find_storage_type" =>  "/account/basicdata-type/storage/type/{storageTypeId}", //GET
-            "create_order"  => "/order/warehouse-order/", //POST
-            "find_order"    => "/order/warehouse-order/{id}",//GET
-            "notifications" => "{order-notification-url}"   //POST
+            "bin_location"  => "/account/binlocation",         //POST
+            "find_all_bin_location" => " /account/binlocation",//GET
+            "delete_bin_location" => " /account/binlocation",  //DELETE
+            "create_storage_type" =>  "/account/basicdata-type/storage/type", //POST
+            "find_storage_type" =>  "/account/basicdata-type/storage/type/", //GET /{storageTypeId}
+            "create_order"  => "/order/warehouse-order", //POST
+            "find_order"    => "/order/warehouse-order/",//GET /{id}
         ],
     ],
 

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

@@ -982,20 +982,20 @@
                     if(this.owner.is_tax_exist && !this.model.express.tax_rate_id)error = {tax_rate_id:["税率不可为空,子项税率必填"]};
                     if (this.model.express.items.length>0){
                         this.model.express.items.forEach((item,index)=>{
-                            if (!item.province_id)error["item."+index+".province_id"] = ["不存在"];
+                            if (!item.province_id)error["items."+index+".province_id"] = ["不存在"];
                             if (!this.model.express.isInterval){
-                                if (!item.initial_weight_price[0][0])error["item."+index+".initial_weight_price.0.0"] = ["不存在"];
-                                if (!item.additional_weight_price[0][0])error["item."+index+".additional_weight_price.0.0"] = ["不存在"];
+                                if (!item.initial_weight_price[0][0])error["items."+index+".initial_weight_price.0.0"] = ["不存在"];
+                                if (!item.additional_weight_price[0][0])error["items."+index+".additional_weight_price.0.0"] = ["不存在"];
                             }else{
-                                item.initial_weight_price.forEach((arr,i)=>{
-                                    arr.forEach((price,j)=>{
-                                        if (!price)error["item."+index+".additional_weight_price."+i+"."+j] = ["不存在"];
-                                    });
-                                });
-                                item.additional_weight_price.forEach((arr,i)=>{
-                                    arr.forEach((price,j)=>{
-                                        if (!price)error["item."+index+".additional_weight_price."+i+"."+j] = ["不存在"];
-                                    });
+                                this.model.express.amount_interval.forEach((amount,i)=>{
+                                    if (this.model.express.weight_interval[i].length>0){
+                                        this.model.express.weight_interval[i].forEach((weight,j)=>{
+                                            if (!item.initial_weight_price[i][j])error["items."+index+".initial_weight_price."+i+"."+j] = ["费用不存在"];
+                                            else item.initial_weight_price[i][j] = (Number)(item.initial_weight_price[i][j]);
+                                            if (!item.additional_weight_price[i][j])error["items."+index+".additional_weight_price."+i+"."+j] = ["费用不存在"];
+                                            else item.additional_weight_price[i][j] = (Number)(item.additional_weight_price[i][j]);
+                                        })
+                                    }
                                 });
                             }
                         });

+ 3 - 3
resources/views/customer/project/part/_three.blade.php

@@ -186,7 +186,7 @@
                 </div>
                 <div class="col-3 pull-right small mb-0 text-secondary" v-if="selectedModel.express.length>0">双击下方已添加内容可编辑</div>
             </div>
-            <div class="card-body w-100 overflow-auto" id="express">
+            <div class="card-body w-100 overflow-auto overflow-scrollbar-200" id="express">
                 <table class="table table-sm">
                     <tr>
                         <th>承运商</th>
@@ -201,7 +201,7 @@
                         <tr>
                             <td>
                                 <div class="small">
-                                    <label v-for="(logistic,j) in express.logistics" class="m-0">@{{ poolMapping.logistics ? poolMapping.logistics[logistic] : '' }}<br></label>
+                                    <p v-for="(logistic,j) in express.logistics" class="m-0">@{{ poolMapping.logistics ? poolMapping.logistics[logistic] : '' }}</p>
                                 </div>
                             </td>
                             <td>@{{ express.name }}</td>
@@ -217,7 +217,7 @@
                         </tr>
                         <tr>
                             <td colspan="5">
-                                <div :id="'express-item-'+i" class="offset-3 up overflow-scrollbar-200">
+                                <div :id="'express-item-'+i" class="offset-1 up">
                                     <table class="table table-sm col-10 text-nowrap">
                                         <tr>
                                             <th>省份</th>

+ 1 - 1
resources/views/maintenance/role/index.blade.php

@@ -9,7 +9,7 @@
                     <label class="pull-left h5 font-weight-bold">角色列表<i class="fa fa-plus cursor-pointer" @click="addRole()"></i></label>
                     <label class="pull-right"><input type="text" class="form-control form-control-sm rounded-pill" placeholder="检索" @keydown.enter="seekRole($event)"></label>
                 </div>
-                <div class="card-body p-0" style="cursor: pointer">
+                <div class="card-body p-0" style="cursor: pointer;overflow-y: auto;max-height: 1000px">
                     <ul class="list-group">
                         <li class="list-group-item" :class="selectedRole==role.id ? 'bg-info' : ''" v-for="(role,i) in roles" v-show="!role.hide" @click="loadRelevance(role.id)">
                             @{{ role.name }}

+ 7 - 0
routes/api/thirdPart/syrius.php

@@ -0,0 +1,7 @@
+<?php
+
+use Illuminate\Support\Facades\Route;
+
+Route::group(['prefix'=>'order'],function (){
+    Route::post("notification","OrderController@receiptNotification");
+});

+ 1 - 1
routes/web.php

@@ -831,6 +831,7 @@ Route::group(['prefix'=>'package'],function(){
     });
     /** 结算 */
     $route->group(['prefix'=>'finance'],function(){
+        Route::get('area','CustomerController@projectArea');
         Route::group(['prefix'=>'instantBill'],function(){
             Route::match(['GET','POST'],'export','CustomerController@financeInstantBillExport');
         });
@@ -936,7 +937,6 @@ Route::group(['prefix'=>'package'],function(){
             Route::group(['prefix'=>'area'],function(){
                 Route::match(['GET','POST'],'export','CustomerController@projectAreaExport');
             });
-            Route::get('area','CustomerController@projectArea');
             Route::get('{id}/edit','CustomerController@projectEdit');
             Route::post('projectUpdate','CustomerController@projectUpdate');
             Route::post('getOwnerPriceModel','CustomerController@getOwnerPriceModel');