|
|
@@ -7,12 +7,10 @@ use App\Order;
|
|
|
use App\OwnerFeeDetail;
|
|
|
use App\OwnerFeeDetailLogistic;
|
|
|
use App\OwnerFeeExpress;
|
|
|
+use App\OwnerFeeLogistic;
|
|
|
use App\Process;
|
|
|
-use App\Province;
|
|
|
use App\RejectedBill;
|
|
|
-use App\Services\CacheService;
|
|
|
use App\Services\OwnerPriceDirectLogisticService;
|
|
|
-use App\Services\OwnerPriceExpressService;
|
|
|
use App\Services\OwnerPriceLogisticService;
|
|
|
use App\Services\OwnerPriceOperationService;
|
|
|
use App\Store;
|
|
|
@@ -22,12 +20,10 @@ use Illuminate\Bus\Queueable;
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
-use Illuminate\Queue\SerializesModels;
|
|
|
-use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
class ResetInstantBill implements ShouldQueue
|
|
|
{
|
|
|
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
+ use Dispatchable, InteractsWithQueue, Queueable;
|
|
|
|
|
|
/** @var \stdClass $detail */
|
|
|
private $detail;
|
|
|
@@ -79,9 +75,8 @@ class ResetInstantBill implements ShouldQueue
|
|
|
"work_tax_fee" => $workTaxFee,
|
|
|
"logistic_tax_fee" => $logisticInfo["logisticTaxFee"],
|
|
|
]);
|
|
|
- //向指定表插入标记 TODO
|
|
|
- //if ($logisticInfo["logisticFee"] && $logisticInfo["fee_info"])OwnerFeeExpress::query()->insert($logisticInfo["fee_info"]);
|
|
|
- /*if ($money>0)app("StoreService")->constructFeeInfo([
|
|
|
+ if ($logisticInfo["logisticFee"] && $logisticInfo["fee_info"])OwnerFeeExpress::query()->insert($logisticInfo["fee_info"]);
|
|
|
+ if ($money>0)app("StoreService")->constructFeeInfo([
|
|
|
"worked_at" => $order->wms_edittime ?: $order->updated_at,
|
|
|
"owner_id" => $order->owner_id,
|
|
|
"model_id" => $id,
|
|
|
@@ -91,7 +86,7 @@ class ResetInstantBill implements ShouldQueue
|
|
|
"total_fee" =>0,
|
|
|
"tax_rate" =>0,
|
|
|
"fee_description"=>'',
|
|
|
- ]);*/
|
|
|
+ ]);
|
|
|
//后续处理
|
|
|
OwnerFeeDetailLogistic::query()->where("owner_fee_detail_id",$this->detail->id)->delete();
|
|
|
foreach ($logisticInfo["items"] as &$item)$item["owner_fee_detail_id"] = $this->detail->id;
|
|
|
@@ -132,7 +127,7 @@ class ResetInstantBill implements ShouldQueue
|
|
|
$service = app("OwnerPriceLogisticService");
|
|
|
list($fee,$taxFee) = $service->matching($waybill->carrier_weight_other,$owner_id,$waybill->logistic_id,
|
|
|
$waybill->carrier_weight_unit_id_other,$provinceId, $cityId);
|
|
|
- //$this->buildWaybillFeeInfo(); TODO
|
|
|
+ if (isset($GLOBALS["FEE_INFO"])) OwnerFeeLogistic::query()->create($GLOBALS["FEE_INFO"]);
|
|
|
}else{
|
|
|
/** @var OwnerPriceDirectLogisticService $service */
|
|
|
$service = app("OwnerPriceDirectLogisticService");
|
|
|
@@ -162,7 +157,7 @@ class ResetInstantBill implements ShouldQueue
|
|
|
"owner_price_operation_id" => $id,
|
|
|
"work_tax_fee" => $taxFee,
|
|
|
]);
|
|
|
- /* if ($money>0)$this->constructFeeInfo([
|
|
|
+ if ($money>0)app("StoreService")->constructFeeInfo([
|
|
|
"worked_at" => $store->updated_at,
|
|
|
"owner_id" => $store->owner_id,
|
|
|
"model_id" => $id,
|
|
|
@@ -172,15 +167,15 @@ class ResetInstantBill implements ShouldQueue
|
|
|
"total_fee" =>0,
|
|
|
"tax_rate" =>0,
|
|
|
"fee_description"=>'',
|
|
|
- ]);*/
|
|
|
+ ]);
|
|
|
break;
|
|
|
case "rejected_bills":
|
|
|
/** @var \stdClass $rejectedBill */
|
|
|
$number = array_column(StoreRejected::query()->where("logistic_number_return",$rejectedBill->logistic_number_return)->get()->toArray(),"store_id");
|
|
|
-
|
|
|
- foreach (Store::query()->with("storeItems")->whereIn("id",$number)->get() as $store){
|
|
|
- /** @var OwnerPriceOperationService $service */
|
|
|
- $service = app("OwnerPriceOperationService");
|
|
|
+ $stores = Store::query()->with("storeItems")->whereIn("id",$number)->get();
|
|
|
+ /** @var OwnerPriceOperationService $service */
|
|
|
+ $service = app("OwnerPriceOperationService");
|
|
|
+ foreach ($stores as $store){
|
|
|
$GLOBALS["FEE_INFO"] = [];
|
|
|
list($id,$money,$taxFee) = $service->matching($store, Feature::MAPPING["store"], $store->owner_id, "入库",0);
|
|
|
app("StoreService")->clearFeeInfo($store->asn_code);
|
|
|
@@ -201,6 +196,28 @@ class ResetInstantBill implements ShouldQueue
|
|
|
"fee_description"=>'',
|
|
|
]);
|
|
|
}
|
|
|
+ if ($stores->count())return;
|
|
|
+ $rejectedBill = RejectedBill::query()->find($this->detail->outer_id);
|
|
|
+ $rejectedBill->loadMissing("items");
|
|
|
+ $GLOBALS["FEE_INFO"] = [];
|
|
|
+ list($id,$money,$taxFee) = $service->matching($rejectedBill, Feature::MAPPING["rejected_bill"], $rejectedBill->id_owner, "入库",0);
|
|
|
+ $this->detail->update([
|
|
|
+ "commodity_amount" => $rejectedBill->goods_amount,
|
|
|
+ "work_fee" => $money,
|
|
|
+ "owner_price_operation_id" => $id,
|
|
|
+ "work_tax_fee" => $taxFee,
|
|
|
+ ]);
|
|
|
+ app("StoreService")->constructFeeInfo([
|
|
|
+ "worked_at" => $rejectedBill->updated_at,
|
|
|
+ "owner_id" => $rejectedBill->id_owner,
|
|
|
+ "model_id" => $id,
|
|
|
+ "source_number"=> null,
|
|
|
+ "doc_number" => null,
|
|
|
+ "commodity_id" => 0,
|
|
|
+ "total_fee" =>0,
|
|
|
+ "tax_rate" =>0,
|
|
|
+ "fee_description"=>'',
|
|
|
+ ]);
|
|
|
}
|
|
|
}
|
|
|
}
|