|
|
@@ -40,38 +40,85 @@ class OrderPackage extends Model
|
|
|
'status',
|
|
|
'sent_at',
|
|
|
'received_at',
|
|
|
- 'exception',
|
|
|
'transfer_status',
|
|
|
'owner_id',
|
|
|
'uploaded_to_wms',
|
|
|
- 'exception_type',
|
|
|
'sync_routes_flag',
|
|
|
];
|
|
|
|
|
|
- public function order(){
|
|
|
- return $this->belongsTo('App\Order','order_id','id');
|
|
|
- }
|
|
|
-
|
|
|
protected $casts = [
|
|
|
'transfer_status' => 'array',
|
|
|
'sync_routes_flag' => 'boolean',
|
|
|
];
|
|
|
|
|
|
+ static public $enums = [
|
|
|
+ 'status' => [
|
|
|
+ ''=>0,
|
|
|
+ '无'=>1,
|
|
|
+ '已称重'=>2,
|
|
|
+ '已揽收'=>3,
|
|
|
+ '揽件异常'=>4,
|
|
|
+ '疑似库内丢件'=>5,
|
|
|
+ '在途'=>6,
|
|
|
+ '在途异常'=>7,
|
|
|
+ '派送中'=>8,
|
|
|
+ '派送异常'=>9,
|
|
|
+ '返回中'=>10,
|
|
|
+ '返回异常'=>11,
|
|
|
+ '返回派件'=>12,
|
|
|
+ '其他异常'=>13,
|
|
|
+ '已收件'=>14,
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+
|
|
|
+ function __construct(array $attributes = [])
|
|
|
+ {
|
|
|
+ foreach (self::$enums as &$enum) {
|
|
|
+ $enum=$enum+array_flip($enum);
|
|
|
+ }
|
|
|
+ parent::__construct($attributes);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getStatusAttribute($value)
|
|
|
+ {
|
|
|
+ if(!$value)return '';
|
|
|
+ return self::$enums['status'][$value];
|
|
|
+ }
|
|
|
+ public function setStatusAttribute($value)
|
|
|
+ {
|
|
|
+ if(!$value)return 0;
|
|
|
+ $this->attributes['status']=self::$enums['status'][$value];
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function switchStatus($value): int
|
|
|
+ {
|
|
|
+ return self::$enums['status'][$value];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function order()
|
|
|
+ {
|
|
|
+ return $this->belongsTo('App\Order', 'order_id', 'id');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public function commodities(): HasMany
|
|
|
{
|
|
|
- return $this->hasMany('App\OrderPackageCommodities','order_package_id','id');
|
|
|
+ return $this->hasMany('App\OrderPackageCommodities', 'order_package_id', 'id');
|
|
|
}
|
|
|
+
|
|
|
public function paperBox(): HasOne
|
|
|
{
|
|
|
- return $this->hasOne('App\PaperBox','id','paper_box_id');
|
|
|
+ return $this->hasOne('App\PaperBox', 'id', 'paper_box_id');
|
|
|
}
|
|
|
+
|
|
|
public function measuringMachine(): HasOne
|
|
|
{
|
|
|
- return $this->hasOne('App\MeasuringMachine','id','measuring_machine_id');
|
|
|
+ return $this->hasOne('App\MeasuringMachine', 'id', 'measuring_machine_id');
|
|
|
}
|
|
|
+
|
|
|
public function WMSReflectPackage(): HasOne
|
|
|
{
|
|
|
- return $this->hasOne('App\WMSReflectPackage','SOReference5','logistic_number');
|
|
|
+ return $this->hasOne('App\WMSReflectPackage', 'SOReference5', 'logistic_number');
|
|
|
}
|
|
|
|
|
|
static protected $oracleOrderHeaderFields = [
|
|
|
@@ -87,24 +134,31 @@ class OrderPackage extends Model
|
|
|
'doc_wave_header.descr',
|
|
|
];
|
|
|
|
|
|
- protected $tempFields=[
|
|
|
- 'temOracleInfo','temOwner','temLogistic',
|
|
|
+ protected $tempFields = [
|
|
|
+ 'temOracleInfo', 'temOwner', 'temLogistic',
|
|
|
];
|
|
|
|
|
|
- public function setLengthAttribute($value){
|
|
|
- if(empty((int)($value)))return;
|
|
|
+ public function setLengthAttribute($value)
|
|
|
+ {
|
|
|
+ if (empty((int)($value))) return;
|
|
|
$this->attributes['length'] = $value;
|
|
|
}
|
|
|
- public function setWidthAttribute($value){
|
|
|
- if(empty((int)($value)))return;
|
|
|
+
|
|
|
+ public function setWidthAttribute($value)
|
|
|
+ {
|
|
|
+ if (empty((int)($value))) return;
|
|
|
$this->attributes['width'] = $value;
|
|
|
}
|
|
|
- public function setHeightAttribute($value){
|
|
|
- if(empty((int)($value)))return;
|
|
|
+
|
|
|
+ public function setHeightAttribute($value)
|
|
|
+ {
|
|
|
+ if (empty((int)($value))) return;
|
|
|
$this->attributes['height'] = $value;
|
|
|
}
|
|
|
- public function setBulkAttribute($value){
|
|
|
- if(empty((int)($value)))return;
|
|
|
+
|
|
|
+ public function setBulkAttribute($value)
|
|
|
+ {
|
|
|
+ if (empty((int)($value))) return;
|
|
|
$this->attributes['bulk'] = $value;
|
|
|
}
|
|
|
|
|
|
@@ -113,196 +167,212 @@ class OrderPackage extends Model
|
|
|
$this->commodities()->delete();
|
|
|
return parent::delete();
|
|
|
}
|
|
|
- public function deleteSafe(){
|
|
|
+
|
|
|
+ public function deleteSafe()
|
|
|
+ {
|
|
|
return parent::delete();
|
|
|
}
|
|
|
|
|
|
- public function isActivityBatch(){
|
|
|
- return ($this['batch_rule'] && strstr($this['batch_rule'],'组合') && $this['batch_number'] );
|
|
|
+ public function isActivityBatch()
|
|
|
+ {
|
|
|
+ return ($this['batch_rule'] && strstr($this['batch_rule'], '组合') && $this['batch_number']);
|
|
|
}
|
|
|
- public function fetchAllFromOracle(){
|
|
|
- if(empty($this->oracleInfo))return null;
|
|
|
-/* $this->fetchOwnerFromOracle();
|
|
|
- $this->fetchLogisticFromOracle();*/
|
|
|
-/* $this['recipient'] = $this->oracleInfo['consigneename'];
|
|
|
- $this['order_code'] = $this->oracleInfo['orderno'];*/
|
|
|
+
|
|
|
+ public function fetchAllFromOracle()
|
|
|
+ {
|
|
|
+ if (empty($this->oracleInfo)) return null;
|
|
|
+ /* $this->fetchOwnerFromOracle();
|
|
|
+ $this->fetchLogisticFromOracle();*/
|
|
|
+ /* $this['recipient'] = $this->oracleInfo['consigneename'];
|
|
|
+ $this['order_code'] = $this->oracleInfo['orderno'];*/
|
|
|
$this['batch_rule'] = $this->oracleInfo['descr'];
|
|
|
-/* $this['recipient_mobile'] = $this->oracleInfo['c_tel2']??$this->oracleInfo['c_tel1'];
|
|
|
- if(!$this['logistic_number']&&$this->oracleInfo['soreference5'])
|
|
|
- $this['logistic_number'] = $this->oracleInfo['soreference5'];*/
|
|
|
- $this['batch_number'] = $this->oracleInfo['waveno']??null;
|
|
|
+ /* $this['recipient_mobile'] = $this->oracleInfo['c_tel2']??$this->oracleInfo['c_tel1'];
|
|
|
+ if(!$this['logistic_number']&&$this->oracleInfo['soreference5'])
|
|
|
+ $this['logistic_number'] = $this->oracleInfo['soreference5'];*/
|
|
|
+ $this['batch_number'] = $this->oracleInfo['waveno'] ?? null;
|
|
|
}
|
|
|
- static public function createPackagesFromBatchCode($batchCode,$weight){
|
|
|
|
|
|
+ static public function createPackagesFromBatchCode($batchCode, $weight)
|
|
|
+ {
|
|
|
|
|
|
|
|
|
- $queryBuilder=OracleDOCOrderHeader::query()->select(self::$oracleOrderHeaderFields);
|
|
|
- $queryBuilder->where('doc_order_header.waveno',$batchCode);
|
|
|
- $queryBuilder->leftJoin('act_allocation_details','act_allocation_details.orderno','doc_order_header.orderno');
|
|
|
- $queryBuilder->leftJoin('doc_wave_header','doc_wave_header.waveno','doc_order_header.waveno');
|
|
|
- $resultOracleObjs=$queryBuilder->get();
|
|
|
- $resultOracleObjs_grouped=$resultOracleObjs->groupBy('soreference5');
|
|
|
+ $queryBuilder = OracleDOCOrderHeader::query()->select(self::$oracleOrderHeaderFields);
|
|
|
+ $queryBuilder->where('doc_order_header.waveno', $batchCode);
|
|
|
+ $queryBuilder->leftJoin('act_allocation_details', 'act_allocation_details.orderno', 'doc_order_header.orderno');
|
|
|
+ $queryBuilder->leftJoin('doc_wave_header', 'doc_wave_header.waveno', 'doc_order_header.waveno');
|
|
|
+ $resultOracleObjs = $queryBuilder->get();
|
|
|
+ $resultOracleObjs_grouped = $resultOracleObjs->groupBy('soreference5');
|
|
|
$packages = [];
|
|
|
$now = Carbon::now();
|
|
|
|
|
|
- foreach($resultOracleObjs_grouped as $resultOracleObj_grouped){
|
|
|
+ foreach ($resultOracleObjs_grouped as $resultOracleObj_grouped) {
|
|
|
$resultOracleObj = $resultOracleObj_grouped[0];
|
|
|
- /** @var OrderService $orderService*/
|
|
|
+ /** @var OrderService $orderService */
|
|
|
$orderService = app('OrderService');
|
|
|
$order = $orderService->logisticNumberFirstOrCreateOrder($resultOracleObj['soreference5']);
|
|
|
- if (!$order){
|
|
|
- app('LogService')->log(__METHOD__,"此包裹在WMS未找到order",json_encode($resultOracleObj),Auth::user()['id']);
|
|
|
+ if (!$order) {
|
|
|
+ app('LogService')->log(__METHOD__, "此包裹在WMS未找到order", json_encode($resultOracleObj), Auth::user()['id']);
|
|
|
continue;
|
|
|
}
|
|
|
- array_push($packages,[
|
|
|
- 'batch_number'=>$batchCode??'',
|
|
|
+ array_push($packages, [
|
|
|
+ 'batch_number' => $batchCode ?? '',
|
|
|
'order_id' => $order->id,
|
|
|
- 'logistic_number'=>$resultOracleObj['soreference5']??'',
|
|
|
- 'weight'=>$weight,
|
|
|
- 'weighed_at'=> $now,
|
|
|
- 'uploaded_to_wms'=>"是",
|
|
|
- "created_at"=>$now,
|
|
|
+ 'logistic_number' => $resultOracleObj['soreference5'] ?? '',
|
|
|
+ 'weight' => $weight,
|
|
|
+ 'weighed_at' => $now,
|
|
|
+ 'uploaded_to_wms' => "是",
|
|
|
+ "created_at" => $now,
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
|
|
|
$packagesLogisticNumbers = array_map(function ($orderPackage) {
|
|
|
return $orderPackage['logistic_number'];
|
|
|
- } ,$packages);
|
|
|
- $existingOrderPackages=OrderPackage::whereIn('logistic_number', $packagesLogisticNumbers)->get();
|
|
|
- $existingLogisticNumbers=$existingOrderPackages->map(function($orderPackage){
|
|
|
+ }, $packages);
|
|
|
+ $existingOrderPackages = OrderPackage::whereIn('logistic_number', $packagesLogisticNumbers)->get();
|
|
|
+ $existingLogisticNumbers = $existingOrderPackages->map(function ($orderPackage) {
|
|
|
return $orderPackage['logistic_number'];
|
|
|
})->toArray();
|
|
|
OrderPackage::whereIn('logistic_number', $existingLogisticNumbers)->update([
|
|
|
- 'batch_number'=>$batchCode??'',
|
|
|
- 'weight'=>$weight,
|
|
|
- 'weighed_at'=> $now,
|
|
|
- 'uploaded_to_wms'=>"是",]);
|
|
|
- $newPackages=$packages;
|
|
|
- if($existingOrderPackages->isNotEmpty())
|
|
|
- $newPackages=array_filter($packages,function ($package)use($existingLogisticNumbers){
|
|
|
- return array_search($package['logistic_number'],$existingLogisticNumbers)===false;
|
|
|
+ 'batch_number' => $batchCode ?? '',
|
|
|
+ 'weight' => $weight,
|
|
|
+ 'weighed_at' => $now,
|
|
|
+ 'uploaded_to_wms' => "是",]);
|
|
|
+ $newPackages = $packages;
|
|
|
+ if ($existingOrderPackages->isNotEmpty())
|
|
|
+ $newPackages = array_filter($packages, function ($package) use ($existingLogisticNumbers) {
|
|
|
+ return array_search($package['logistic_number'], $existingLogisticNumbers) === false;
|
|
|
});
|
|
|
- DB::transaction(function ()use($newPackages){
|
|
|
+ DB::transaction(function () use ($newPackages) {
|
|
|
OrderPackage::query()->insert($newPackages);
|
|
|
});
|
|
|
|
|
|
|
|
|
- app('LogService')->log(__METHOD__,"批量录入包裹成功",json_encode($packages),Auth::user()['id']);
|
|
|
+ app('LogService')->log(__METHOD__, "批量录入包裹成功", json_encode($packages), Auth::user()['id']);
|
|
|
}
|
|
|
- public function unifyThisMeasureUnderSameBatch(){
|
|
|
+
|
|
|
+ public function unifyThisMeasureUnderSameBatch()
|
|
|
+ {
|
|
|
$this->fetchPaperBox();
|
|
|
- $params=[];
|
|
|
- !empty($this['weight'])?$params['weight']= $this['weight']:null;
|
|
|
- !empty($this['length'])?$params['length']= $this['length']:null;
|
|
|
- !empty($this['width'])?$params['width']= $this['width']:null;
|
|
|
- !empty($this['height'])?$params['height']= $this['height']:null;
|
|
|
- !empty($this['bulk'])?$params['bulk']= $this['bulk']:null;
|
|
|
- !empty($this['measuring_machine_id'])?$params['measuring_machine_id']= $this['measuring_machine_id']:null;
|
|
|
- !empty($this['weighed_at'])?$params['weighed_at']= $this['weighed_at']:null;
|
|
|
- !empty($this['paper_box_id'])?$params['paper_box_id']= $this['paper_box_id']:null;
|
|
|
- if(empty($params)||empty($this['batch_number']))return;
|
|
|
- OrderPackage::query()->where(['batch_number'=>$this['batch_number']])->update($params);
|
|
|
+ $params = [];
|
|
|
+ !empty($this['weight']) ? $params['weight'] = $this['weight'] : null;
|
|
|
+ !empty($this['length']) ? $params['length'] = $this['length'] : null;
|
|
|
+ !empty($this['width']) ? $params['width'] = $this['width'] : null;
|
|
|
+ !empty($this['height']) ? $params['height'] = $this['height'] : null;
|
|
|
+ !empty($this['bulk']) ? $params['bulk'] = $this['bulk'] : null;
|
|
|
+ !empty($this['measuring_machine_id']) ? $params['measuring_machine_id'] = $this['measuring_machine_id'] : null;
|
|
|
+ !empty($this['weighed_at']) ? $params['weighed_at'] = $this['weighed_at'] : null;
|
|
|
+ !empty($this['paper_box_id']) ? $params['paper_box_id'] = $this['paper_box_id'] : null;
|
|
|
+ if (empty($params) || empty($this['batch_number'])) return;
|
|
|
+ OrderPackage::query()->where(['batch_number' => $this['batch_number']])->update($params);
|
|
|
}
|
|
|
- public function fetchLogisticFromOracle(){
|
|
|
- if(empty($this->oracleInfo))return null;
|
|
|
- if(Arr::exists($this->tempFields,'temLogistic'))return $this->tempFields['temLogistic'];
|
|
|
- Controller::logs(__METHOD__, __FUNCTION__, "tempPackage:{$this->oracleInfo['carrierid']}||SOR:{$this->oracleInfo['SOReference5']}||sor:{$this->oracleInfo['soreference5']}||orderno:{$this['orderno']}" , null);
|
|
|
- if(!$this->oracleInfo['carrierid'])return null;
|
|
|
- $logistic= Logistic::query()->where('code',$this->oracleInfo['carrierid'])->first();
|
|
|
- if(!$logistic){
|
|
|
- $logistic=Logistic::query()->create(['code'=>$this->oracleInfo['carrierid'],'name'=>$this->oracleInfo['carrierid']]);
|
|
|
- Controller::logs(__METHOD__, __FUNCTION__, "富勒下发找不到快递公司,添加{$this->oracleInfo['carrierid']}" , null);
|
|
|
+
|
|
|
+ public function fetchLogisticFromOracle()
|
|
|
+ {
|
|
|
+ if (empty($this->oracleInfo)) return null;
|
|
|
+ if (Arr::exists($this->tempFields, 'temLogistic')) return $this->tempFields['temLogistic'];
|
|
|
+ Controller::logs(__METHOD__, __FUNCTION__, "tempPackage:{$this->oracleInfo['carrierid']}||SOR:{$this->oracleInfo['SOReference5']}||sor:{$this->oracleInfo['soreference5']}||orderno:{$this['orderno']}", null);
|
|
|
+ if (!$this->oracleInfo['carrierid']) return null;
|
|
|
+ $logistic = Logistic::query()->where('code', $this->oracleInfo['carrierid'])->first();
|
|
|
+ if (!$logistic) {
|
|
|
+ $logistic = Logistic::query()->create(['code' => $this->oracleInfo['carrierid'], 'name' => $this->oracleInfo['carrierid']]);
|
|
|
+ Controller::logs(__METHOD__, __FUNCTION__, "富勒下发找不到快递公司,添加{$this->oracleInfo['carrierid']}", null);
|
|
|
}
|
|
|
- Controller::logs(__METHOD__, __FUNCTION__, "tempPackage2:{$logistic->id}" , null);
|
|
|
- if(!$logistic)return null;
|
|
|
- $this->tempFields['temLogistic']=$logistic;
|
|
|
+ Controller::logs(__METHOD__, __FUNCTION__, "tempPackage2:{$logistic->id}", null);
|
|
|
+ if (!$logistic) return null;
|
|
|
+ $this->tempFields['temLogistic'] = $logistic;
|
|
|
$this['logistic_id'] = $logistic['id'];
|
|
|
return $logistic;
|
|
|
}
|
|
|
- public function fetchOwnerFromOracle(){
|
|
|
- if(empty($this->oracleInfo))return null;
|
|
|
- if(Arr::exists($this->tempFields,'temOwner'))return $this->tempFields['temOwner'];
|
|
|
- $owner= Owner::query()->where('code',$this->oracleInfo['customerid'])->first();
|
|
|
- if(!$owner){
|
|
|
- $owner=Owner::query()->create(['code'=>$this->oracleInfo['customerid'],'name'=>$this->oracleInfo['customerid']]);
|
|
|
- Controller::logs(__METHOD__, __FUNCTION__, "富勒下发找不到货主,添加{$this->oracleInfo['customerid']}" , null);
|
|
|
+
|
|
|
+ public function fetchOwnerFromOracle()
|
|
|
+ {
|
|
|
+ if (empty($this->oracleInfo)) return null;
|
|
|
+ if (Arr::exists($this->tempFields, 'temOwner')) return $this->tempFields['temOwner'];
|
|
|
+ $owner = Owner::query()->where('code', $this->oracleInfo['customerid'])->first();
|
|
|
+ if (!$owner) {
|
|
|
+ $owner = Owner::query()->create(['code' => $this->oracleInfo['customerid'], 'name' => $this->oracleInfo['customerid']]);
|
|
|
+ Controller::logs(__METHOD__, __FUNCTION__, "富勒下发找不到货主,添加{$this->oracleInfo['customerid']}", null);
|
|
|
}
|
|
|
- if(!$owner)return null;
|
|
|
- $this->tempFields['temOwner']=$owner;
|
|
|
+ if (!$owner) return null;
|
|
|
+ $this->tempFields['temOwner'] = $owner;
|
|
|
$this['owner_id'] = $owner['id'];
|
|
|
return $owner;
|
|
|
}
|
|
|
+
|
|
|
//寻找相近纸箱ID
|
|
|
- public function fetchPaperBox($max=null, $centre=null, $min=null, $owner_id=null){
|
|
|
- if($this['paper_box_id'])return $this['paper_box_id'];
|
|
|
- $sumDiffer=0;
|
|
|
- $maxDiffer=0;
|
|
|
- $paperBox_id=null;
|
|
|
- if(!$max)$max=$this['length'];
|
|
|
- if(!$centre)$centre=$this['width'];
|
|
|
- if(!$min)$min=$this['height'];
|
|
|
- if(!$owner_id) $owner_id = $this['order'] ? $this['order']['owner_id'] : null;
|
|
|
- if(!$owner_id) {
|
|
|
+ public function fetchPaperBox($max = null, $centre = null, $min = null, $owner_id = null)
|
|
|
+ {
|
|
|
+ if ($this['paper_box_id']) return $this['paper_box_id'];
|
|
|
+ $sumDiffer = 0;
|
|
|
+ $maxDiffer = 0;
|
|
|
+ $paperBox_id = null;
|
|
|
+ if (!$max) $max = $this['length'];
|
|
|
+ if (!$centre) $centre = $this['width'];
|
|
|
+ if (!$min) $min = $this['height'];
|
|
|
+ if (!$owner_id) $owner_id = $this['order'] ? $this['order']['owner_id'] : null;
|
|
|
+ if (!$owner_id) {
|
|
|
$owner = $this->fetchOwnerFromOracle();
|
|
|
$owner_id = $owner['id'];
|
|
|
- if(!$owner_id)return null;
|
|
|
+ if (!$owner_id) return null;
|
|
|
}
|
|
|
- $boxes=Owner::select('id')->with('paperBoxes')->find($owner_id);
|
|
|
- $targetPaperBox=null;
|
|
|
- foreach ($boxes->paperBoxes as $i=>$paperBox){
|
|
|
- if ($paperBox->length==$max&&$paperBox->width==$centre&&$paperBox->height==$min){
|
|
|
- $targetPaperBox=$paperBox;
|
|
|
+ $boxes = Owner::select('id')->with('paperBoxes')->find($owner_id);
|
|
|
+ $targetPaperBox = null;
|
|
|
+ foreach ($boxes->paperBoxes as $i => $paperBox) {
|
|
|
+ if ($paperBox->length == $max && $paperBox->width == $centre && $paperBox->height == $min) {
|
|
|
+ $targetPaperBox = $paperBox;
|
|
|
break;
|
|
|
}
|
|
|
- $lengthDiffer=abs($paperBox->length-$max);
|
|
|
- $widthDiffer=abs($paperBox->width-$centre);
|
|
|
- $heightDiffer=abs($paperBox->height-$min);
|
|
|
- $thisMaxDiffer=($lengthDiffer>=($widthDiffer>=$heightDiffer?$widthDiffer:$heightDiffer)?$lengthDiffer:($widthDiffer>=$heightDiffer?$widthDiffer:$heightDiffer));
|
|
|
- if($i==0){
|
|
|
- $maxDiffer=$thisMaxDiffer;
|
|
|
- $sumDiffer=$lengthDiffer+$widthDiffer+$heightDiffer;
|
|
|
- $targetPaperBox=$paperBox;
|
|
|
+ $lengthDiffer = abs($paperBox->length - $max);
|
|
|
+ $widthDiffer = abs($paperBox->width - $centre);
|
|
|
+ $heightDiffer = abs($paperBox->height - $min);
|
|
|
+ $thisMaxDiffer = ($lengthDiffer >= ($widthDiffer >= $heightDiffer ? $widthDiffer : $heightDiffer) ? $lengthDiffer : ($widthDiffer >= $heightDiffer ? $widthDiffer : $heightDiffer));
|
|
|
+ if ($i == 0) {
|
|
|
+ $maxDiffer = $thisMaxDiffer;
|
|
|
+ $sumDiffer = $lengthDiffer + $widthDiffer + $heightDiffer;
|
|
|
+ $targetPaperBox = $paperBox;
|
|
|
}
|
|
|
- if ($thisMaxDiffer==$maxDiffer){
|
|
|
- if($sumDiffer>($lengthDiffer+$widthDiffer+$heightDiffer)){
|
|
|
- $sumDiffer=$lengthDiffer+$widthDiffer+$heightDiffer;
|
|
|
- $targetPaperBox=$paperBox;
|
|
|
+ if ($thisMaxDiffer == $maxDiffer) {
|
|
|
+ if ($sumDiffer > ($lengthDiffer + $widthDiffer + $heightDiffer)) {
|
|
|
+ $sumDiffer = $lengthDiffer + $widthDiffer + $heightDiffer;
|
|
|
+ $targetPaperBox = $paperBox;
|
|
|
}
|
|
|
}
|
|
|
- if ($thisMaxDiffer<$maxDiffer){
|
|
|
- $sumDiffer=$lengthDiffer+$widthDiffer+$heightDiffer;
|
|
|
- $maxDiffer=$thisMaxDiffer;
|
|
|
- $targetPaperBox=$paperBox;
|
|
|
+ if ($thisMaxDiffer < $maxDiffer) {
|
|
|
+ $sumDiffer = $lengthDiffer + $widthDiffer + $heightDiffer;
|
|
|
+ $maxDiffer = $thisMaxDiffer;
|
|
|
+ $targetPaperBox = $paperBox;
|
|
|
}
|
|
|
}
|
|
|
- if($targetPaperBox)$this['paper_box_id']=$targetPaperBox['id'];
|
|
|
+ if ($targetPaperBox) $this['paper_box_id'] = $targetPaperBox['id'];
|
|
|
return $targetPaperBox['id'];
|
|
|
}
|
|
|
+
|
|
|
public function getOracleInfoAttribute()
|
|
|
{
|
|
|
- if(isset($this->tempFields['temOracleInfo']))return $this->tempFields['temOracleInfo'];
|
|
|
- if(empty($this['logistic_number'])&&empty($this['order_code']))return '';
|
|
|
- if($this['order_code']){
|
|
|
- $resultOracleObjs=OracleDOCOrderHeader::query()->select(self::$oracleOrderHeaderFields)->where('orderno',$this['order_code']);
|
|
|
- $resultOracleObjs->leftJoin('doc_wave_header','doc_wave_header.waveno','doc_order_header.waveno');
|
|
|
- }else{
|
|
|
- $resultOracleObjs=OracleActAllocationDetails::query()->select(self::$oracleOrderHeaderFields);
|
|
|
- $resultOracleObjs->where('picktotraceid',$this['logistic_number']);
|
|
|
- $resultOracleObjs->leftJoin('DOC_Order_Header','act_allocation_details.orderno','doc_order_header.orderno');
|
|
|
- $resultOracleObjs->leftJoin('doc_wave_header','doc_wave_header.waveno','doc_order_header.waveno');
|
|
|
+ if (isset($this->tempFields['temOracleInfo'])) return $this->tempFields['temOracleInfo'];
|
|
|
+ if (empty($this['logistic_number']) && empty($this['order_code'])) return '';
|
|
|
+ if ($this['order_code']) {
|
|
|
+ $resultOracleObjs = OracleDOCOrderHeader::query()->select(self::$oracleOrderHeaderFields)->where('orderno', $this['order_code']);
|
|
|
+ $resultOracleObjs->leftJoin('doc_wave_header', 'doc_wave_header.waveno', 'doc_order_header.waveno');
|
|
|
+ } else {
|
|
|
+ $resultOracleObjs = OracleActAllocationDetails::query()->select(self::$oracleOrderHeaderFields);
|
|
|
+ $resultOracleObjs->where('picktotraceid', $this['logistic_number']);
|
|
|
+ $resultOracleObjs->leftJoin('DOC_Order_Header', 'act_allocation_details.orderno', 'doc_order_header.orderno');
|
|
|
+ $resultOracleObjs->leftJoin('doc_wave_header', 'doc_wave_header.waveno', 'doc_order_header.waveno');
|
|
|
}
|
|
|
- $this->tempFields['temOracleInfo']=$resultOracleObjs->first();
|
|
|
- if(empty($this->tempFields['temOracleInfo'])) {
|
|
|
- $resultOracleObjs=OracleDOCOrderHeader::query()->select(self::$oracleOrderHeaderFields)->where('soreference5',$this['logistic_number']);
|
|
|
- $resultOracleObjs->leftJoin('doc_wave_header','doc_wave_header.waveno','doc_order_header.waveno');
|
|
|
+ $this->tempFields['temOracleInfo'] = $resultOracleObjs->first();
|
|
|
+ if (empty($this->tempFields['temOracleInfo'])) {
|
|
|
+ $resultOracleObjs = OracleDOCOrderHeader::query()->select(self::$oracleOrderHeaderFields)->where('soreference5', $this['logistic_number']);
|
|
|
+ $resultOracleObjs->leftJoin('doc_wave_header', 'doc_wave_header.waveno', 'doc_order_header.waveno');
|
|
|
}
|
|
|
- $this->tempFields['temOracleInfo']=$resultOracleObjs->first();
|
|
|
+ $this->tempFields['temOracleInfo'] = $resultOracleObjs->first();
|
|
|
return $this->tempFields['temOracleInfo'];
|
|
|
}
|
|
|
+
|
|
|
public function getLogisticNumberAttribute($val)
|
|
|
{
|
|
|
- if(strpos($val,'null')!==false)return '';
|
|
|
+ if (strpos($val, 'null') !== false) return '';
|
|
|
return $val;
|
|
|
}
|
|
|
|