|
@@ -8,6 +8,7 @@ use Illuminate\Bus\Queueable;
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
class PackageCollectingAllocation implements ShouldQueue
|
|
class PackageCollectingAllocation implements ShouldQueue
|
|
@@ -17,18 +18,14 @@ class PackageCollectingAllocation implements ShouldQueue
|
|
|
/** @var OrderPackage|\stdClass $orderPackage */
|
|
/** @var OrderPackage|\stdClass $orderPackage */
|
|
|
private $orderPackage;
|
|
private $orderPackage;
|
|
|
|
|
|
|
|
- /** @var int|null|string */
|
|
|
|
|
- private $lineNo;
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Create a new job instance.
|
|
* Create a new job instance.
|
|
|
*
|
|
*
|
|
|
* @return void
|
|
* @return void
|
|
|
*/
|
|
*/
|
|
|
- public function __construct(OrderPackage $package,int $lineNo)
|
|
|
|
|
|
|
+ public function __construct(OrderPackage $package)
|
|
|
{
|
|
{
|
|
|
$this->orderPackage = $package;
|
|
$this->orderPackage = $package;
|
|
|
- $this->lineNo = $lineNo;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -40,21 +37,23 @@ class PackageCollectingAllocation implements ShouldQueue
|
|
|
{
|
|
{
|
|
|
/** @var OrderPackageService $orderPackageService */
|
|
/** @var OrderPackageService $orderPackageService */
|
|
|
$orderPackageService = app('OrderPackageService');
|
|
$orderPackageService = app('OrderPackageService');
|
|
|
- $result = $orderPackageService->collectUpload([$this->orderPackage->logistic_number]);
|
|
|
|
|
- if (!$result["success"]){
|
|
|
|
|
- Log::warning("自动揽收失败",["message"=>$result["message"],"param"=>$this->orderPackage->logistic_number]);
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+ try {
|
|
|
|
|
+ $result = OrderPackage::query()->where("id",$this->orderPackage->id)
|
|
|
|
|
+ ->where("collecting_status",0)->update(["collecting_status"=>1]);
|
|
|
|
|
+ if ($result==1){
|
|
|
|
|
+ $result = $orderPackageService->collectUpload([$this->orderPackage->logistic_number]);
|
|
|
|
|
+ if (!$result["success"]){
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ Log::warning("自动揽收失败",["message"=>$result["message"],"param"=>$this->orderPackage->logistic_number]);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }else Log::info("揽收成功",["id"=>$this->orderPackage->id,"number"=>$this->orderPackage->logistic_number]);
|
|
|
|
|
+ }else Log::warning("自动揽收异常",["message"=>"未能成功修改揽收标记","param"=>["id"=>$this->orderPackage->id,
|
|
|
|
|
+ "number"=>$this->orderPackage->logistic_number],"line"=>$result]);
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ }catch (\Exception $e){
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ Log::warning("自动揽收错误",["param"=>$this->orderPackage->toJson()]);
|
|
|
}
|
|
}
|
|
|
- $result = OrderPackage::query()->where("id",$this->orderPackage->id)
|
|
|
|
|
- ->where("collecting_status",'0')->update(["collecting_status"=>'1']);
|
|
|
|
|
- if ($result!=1)
|
|
|
|
|
- Log::warning("自动揽收异常",["message"=>"未能成功修改揽收标记","param"=>["id"=>$this->orderPackage->id,"number"=>$this->orderPackage->logistic_number],"line"=>$result]);
|
|
|
|
|
- else Log::info("揽收成功",["id"=>$this->orderPackage->id,"number"=>$this->orderPackage->logistic_number]);
|
|
|
|
|
- /*$result = app("OrderService")->allocation($this->orderPackage->order->code,$this->lineNo);
|
|
|
|
|
- if (mb_substr($result,0,3)=='000'){
|
|
|
|
|
- if (OrderPackage::query()->where("id",$this->orderPackage->id)
|
|
|
|
|
- ->where("collecting_status",'0')->update(["collecting_status"=>'1'])!=1)
|
|
|
|
|
- Log::warning("自动揽收异常",["message"=>"未能成功修改揽收标记","param"=>$this->orderPackage->toArray()]);
|
|
|
|
|
- }else Log::warning("自动揽收失败",["message"=>"分配失败:{$result}","param"=>$this->orderPackage->order->code." : {$this->lineNo}"]);*/
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|