Просмотр исходного кода

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

LD 4 лет назад
Родитель
Сommit
ce4b4dd680

+ 11 - 7
app/Http/Controllers/CustomerController.php

@@ -552,27 +552,31 @@ class CustomerController extends Controller
         $owner = request("owner");
         $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 ? 
+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 (''";
             foreach ($owner as $o)$sql .=",'{$o}'";
             $sql.=")";
         }
-        $sql .= " 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";
+        $sql .= " GROUP BY owner_id";
 
         $billDetails = DB::select(DB::raw($sql),[$month."%"]);
 
-        $areas = OwnerAreaReport::query()->with("ownerStoragePriceModel")->where("counting_month","like",$month."%")->get();
+        $areas = OwnerAreaReport::query()->with(["ownerStoragePriceModel.timeUnit","ownerStoragePriceModel.taxRate"])->where("counting_month","like",$month."%")->get();
         $map = [];
+        $mapTax = [];
         foreach($areas as $area){
-            if (isset($map[$area->owner_id."_".$area->counting_month])){
+            $key = $area->owner_id."_".$area->counting_month;
+            if (isset($map[$key])){
                 if (!$area->ownerStoragePriceModel)continue;
-                $map[$area->owner_id."_".$area->counting_month] += app('OwnerStoragePriceModelService')
+                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;
-                $map[$area->owner_id."_".$area->counting_month] = app('OwnerStoragePriceModelService')
+                list($map[$key],$mapTax[$key]) = app('OwnerStoragePriceModelService')
                     ->calculationAmount($area->ownerStoragePriceModel,$area->accounting_area,$area->owner_id,$area->counting_month);
             }
         }
@@ -583,7 +587,7 @@ sql;
                 $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]);
+                    ->update(["work_fee"=>$bill->work_fee,"logistic_fee"=>$bill->logistic_fee,"storage_fee"=>$map[$key] ?? 0,"storage_tax_fee"   => $mapTax[$key] ?? 0]);
             }
         }
         $this->success();

+ 3 - 43
app/Http/Controllers/TestController.php

@@ -123,49 +123,9 @@ class TestController extends Controller
     }
     public function test()
     {
-        dd();
-        $sql = "SELECT ORDERNO,WAVENO,SEQNO,EDITTIME FROM DOC_WAVE_DETAILS WHERE WAVENO = 'W210526000315'";
-        $details = DB::connection("oracle")->select(DB::raw($sql));
-        $this->detailExe($details);
-        dd();
-        $asnno = "ASN2105240178";
-        $query = DB::raw("SELECT b.ALTERNATE_SKU1,h.WAREHOUSEID,h.asnno,d.ASNLINENO,d.SKUDESCRC,h.CUSTOMERID,d.SKU,d.PACKID,d.RECEIVEDQTY_EACH,d.EXPECTEDQTY_EACH,d.LOTATT01,d.LOTATT02,d.lotatt04,".
-            "d.lotatt05,d.lotatt08,d.USERDEFINE1,d.USERDEFINE2,d.USERDEFINE3,d.USERDEFINE4,d.USERDEFINE5,d.RECEIVINGLOCATION FROM DOC_ASN_DETAILS d ".
-            " LEFT JOIN BAS_SKU b ON d.CUSTOMERID = b.CUSTOMERID AND d.SKU = b.SKU INNER JOIN DOC_ASN_HEADER h ON d.ASNNO = h.ASNNO WHERE h.ASNNO = ?");
-        $detail = DB::connection("oracle")->selectOne($query,[$asnno]);
-        //dd($detail);
-        $ser = new StoreService();
-        $result = $ser->warehousing(array(
-            "IN_Warehouse" => $detail->warehouseid ?? '',
-            "In_ASNNo_C" => $detail->asnno ?? '',
-            "In_ASNLineNo_C" => $detail->asnlineno ?? '',
-            "In_New_TraceID_C" => (string)rand(100,999),
-            "In_CustomerID" => $detail->customerid ?? '',
-            "In_SKU" => $detail->sku ?? '',
-            "In_ReceivedQty" => (string)((int)$detail->expectedqty_each - (int)$detail->receivedqty_each) ?? '',
-            "In_PackID" => $detail->packid ?? '',
-            "In_LotAtt01_C" => $detail->lotatt01 ?? '',
-            "In_LotAtt02_C" => $detail->lotatt02 ?? '',
-            "In_LotAtt04_C" => $detail->lotatt04 ?? '',
-            "In_LotAtt05_C" => $detail->lotatt05 ?? '',
-            "In_LotAtt08_C" => $detail->lotatt08 ?? '',
-            "In_UserDefine1" => $detail->userdefine1 ?? '',
-            "In_UserDefine2" => $detail->userdefine2 ?? '',
-            "In_UserDefine3" => $detail->userdefine3 ?? '',
-            "In_UserDefine4" => $detail->userdefine4 ?? '',
-            "In_UserDefine5" => $detail->userdefine5 ?? '',
-            "In_FMLocation"  => 'STAGE' . $detail->warehouseid,
-            "In_TOLocation_C" => 'STAGE' . $detail->warehouseid,//'IDE0000001',
-        ));
-       dd($result);
-        /*$order = Order::query()->where("code","SO210511005663")->first();
-        $ser = new OrderService();
-        $ser->createInstantBill($order);
-        dd();*/
-        $store = Store::query()->find(173382);dd($store->load("storeItems.commodity"));
-        $ser = new StoreService();
-        $ser->createInstantBill($store);
-        dd($store);
+        foreach(Owner::query()->get() as $owner)app("OwnerService")->refreshRelevance($owner->id);
+
+        dd("OK");
     }
     public function orderCreateBill()
     {

+ 3 - 0
app/Providers/AuthServiceProvider.php

@@ -38,6 +38,9 @@ class AuthServiceProvider extends ServiceProvider
     public function boot()
     {
         $this->registerPolicies();
+        Gate::before(function ($user){
+            if (config("app.env") == 'local')return true;
+        });
         $isSuperAdmin = null;
         if(!Schema::hasTable('users')){return;}
         /** @var CacheService $cacheService */

+ 2 - 5
app/Services/OrderService.php

@@ -6,7 +6,6 @@ use App\Commodity;
 use App\Feature;
 use App\Jobs\OrderCreateInstantBill;
 use App\Jobs\OrderFreeze;
-use App\Log;
 use App\Logistic;
 use App\OracleActAllocationDetails;
 use App\OracleDOCASNHeader;
@@ -17,7 +16,6 @@ use App\OrderIssue;
 use App\Owner;
 use App\OwnerFeeDetail;
 use App\OwnerFeeDetailLogistic;
-use App\OwnerPriceExpress;
 use App\OwnerReport;
 use App\Province;
 use App\RejectedBill;
@@ -30,7 +28,6 @@ use App\Warehouse;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Collection;
-use Illuminate\Support\Facades\App;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
 use App\Traits\ServiceAppAop;
@@ -1320,7 +1317,7 @@ sql
         $order->loadMissing("packages","owner");//加载包裹
         if (!$order->packages || !$order->owner)return false;
         $order->owner->loadCount("ownerPriceExpresses");
-        if ($order->owner->owner_price_expresses_count < 1)return false; //不存在计费模型 跳出
+        //if ($order->owner->owner_price_expresses_count < 1)return false; //不存在计费模型 跳出
         foreach ($order->packages as $package)if (!$package->weight)return false; //包裹存在且全部存在数量
 
         $logistic_fee = 0;
@@ -1363,7 +1360,7 @@ sql
             $taxFee += $tax;
         }
         if ($isBunched && !$weightExceptionMark && $weight>0 && $provinceId)list($logistic_fee,$taxFee) = app("OwnerPriceExpressService")->matching($weight, $order->owner_id, $order->logistic_id, $provinceId);
-        if ($logistic_fee!==null && $logistic_fee>0) $feeBill->update(["logistic_fee"=>$logistic_fee,"volume"=>$volume,"weight"=>$weight,"logistic_tax_fee"=>$taxFee]);
+        $feeBill->update(["logistic_fee"=>$logistic_fee,"volume"=>$volume,"weight"=>$weight,"logistic_tax_fee"=>$taxFee]);
         return true;
     }
 

+ 2 - 2
app/Services/OwnerAreaReportService.php

@@ -62,8 +62,8 @@ class OwnerAreaReportService
                     ->where("counting_month",'like',$area->counting_month."%")->first();
                 if ($report){
                     if (!$area->ownerStoragePriceModel)return false;
-                    $storeFee = app("OwnerStoragePriceModelService")->calculationAmount($area->ownerStoragePriceModel, $values["accounting_area"], $area->owner_id, $area->counting_month);
-                    $up = ["storage_fee"=>$storeFee];
+                    list($storeFee,$taxFee) = app("OwnerStoragePriceModelService")->calculationAmount($area->ownerStoragePriceModel, $values["accounting_area"], $area->owner_id, $area->counting_month);
+                    $up = ["storage_fee"=>$storeFee,"storage_tax_fee"=>$taxFee];
                     if ($report->confirm_fee !== null || $report->confirmed == '是'){
                         $initial = $report->work_fee + $report->logistic_fee + $storeFee;
                         $up["difference"] = $initial - $report->confirm_fee;