|
|
@@ -109,7 +109,7 @@ class OrderPackageCommoditiesService
|
|
|
unset($details,$orderPackageCommodities);
|
|
|
}
|
|
|
|
|
|
- public function basedOnActAllocationDetail(Order $order, OracleDOCOrderHeader $header, array $details)
|
|
|
+/* public function basedOnActAllocationDetail(Order $order, OracleDOCOrderHeader $header, array $details)
|
|
|
{
|
|
|
foreach ($details as $detail) {
|
|
|
$logistic_number = $details['picktotraceid'];
|
|
|
@@ -122,9 +122,9 @@ class OrderPackageCommoditiesService
|
|
|
$orderPackage = OrderPackage::query()->firstOrCreate(['order_id'=>$order['id'],'logistic_number',$details]);
|
|
|
$this->createByActAllocationDetail($detail, $orderPackage);
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
- private function createByActAllocationDetail($detail,$orderPackage)
|
|
|
+ /* private function createByActAllocationDetail($detail,$orderPackage)
|
|
|
{
|
|
|
$owner = Owner::query()->where(['code' => $detail->customerid])->first(); // 货主
|
|
|
$sku = $detail->sku;
|
|
|
@@ -145,84 +145,41 @@ class OrderPackageCommoditiesService
|
|
|
} finally {
|
|
|
return $orderPackageCommodities ?? null;
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
public function createByWmsOrder($orderHeaders)
|
|
|
{
|
|
|
if(!$orderHeaders){ return [];}
|
|
|
$this->更新OPC_根据WMS订单($orderHeaders);
|
|
|
-// /** @var DataHandlerService $dataHandlerService */
|
|
|
-// $dataHandlerService = app(DataHandlerService::class);
|
|
|
-//
|
|
|
-// $order_packages = app(OrderPackageService::class)->getByWmsOrders($orderHeaders);
|
|
|
-// $order_packages_logistic_number_map = $dataHandlerService->dataHeader(['logistic_number'],$order_packages);
|
|
|
-//
|
|
|
-// $commodities = app(CommodityService::class)->getByWmsOrders($orderHeaders);
|
|
|
-// $commodity_owner_id_sku_map = $dataHandlerService->dataHeader(['owner_id','sku'],$commodities);
|
|
|
-//
|
|
|
-// $owners = app(OwnerService::class)->getByWmsOrders($orderHeaders);
|
|
|
-// $owner_code_map = $dataHandlerService->dataHeader(['code'],$owners);
|
|
|
-//
|
|
|
-// $order_packages_commodities = $this->getByWmsOrder($orderHeaders);
|
|
|
-// $map = [];
|
|
|
-// foreach ($order_packages_commodities as $item) {
|
|
|
-// $key = ' commodity_id='.$item->commodity_id.' order_package_id'.$item->order_package_id.' amount='.$item->amount;
|
|
|
-// $map[$key][] = $item;
|
|
|
-// }
|
|
|
-// $insert_params = [];
|
|
|
-// foreach ($orderHeaders as $orderHeader) {
|
|
|
-// $actAllocationDetails = $orderHeader->actAllocationDetails;
|
|
|
-// $logistic_numbers = array_diff(array_unique(data_get($actAllocationDetails,'*.picktotraceid')),['*','',null]);
|
|
|
-// if(count($logistic_numbers) > 0){
|
|
|
-// $params = $this->getParamsByActAllocationDetails($actAllocationDetails,
|
|
|
-// $order_packages_logistic_number_map,
|
|
|
-// $owner_code_map,
|
|
|
-// $commodity_owner_id_sku_map,
|
|
|
-// $logistic_numbers);
|
|
|
-// foreach ($params as $key =>$param) {
|
|
|
-// $mapkey = ' commodity_id='.($param['commodity_id'] ?? '').' order_package_id'.($param['order_package_id'] ?? '').' amount='.($param['amount'] ?? '');
|
|
|
-// if(($map[$mapkey] ?? false) && count($map[$mapkey]) >0){
|
|
|
-// array_shift($map[$mapkey]);
|
|
|
-// unset($params[$key]);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// $insert_params = array_merge($insert_params,$params);
|
|
|
-// unset($params);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// if(count($insert_params) > 0){
|
|
|
-// $this->create($insert_params);
|
|
|
-// }
|
|
|
-// unset($orderHeaders,$order_packages,$owner_code_map,$commodities,$insert_params);
|
|
|
}
|
|
|
|
|
|
- public function getParamsByActAllocationDetails($details,array $order_packages_logistic_number_map,array $owner_code_map,array $commodity_owner_id_sku_map,array $logistic_numbers){
|
|
|
- /** @var DataHandlerService $dataHandlerService */
|
|
|
- $dataHandlerService = app(DataHandlerService::class);
|
|
|
- if(!$details)return [];
|
|
|
- $params = [];
|
|
|
- $create_at = Carbon::now()->format('Y-m-d H:i:s');
|
|
|
- $updated_at = Carbon::now()->format('Y-m-d H:i:s');
|
|
|
- foreach ($details as $actAllocationDetail) {
|
|
|
- $pickToTraceID = $actAllocationDetail->picktotraceid;
|
|
|
- if(in_array($pickToTraceID,$logistic_numbers)){
|
|
|
- $orderPackage = $dataHandlerService->getKeyValue(['logistic_number'=>$pickToTraceID],$order_packages_logistic_number_map);
|
|
|
- if(!$orderPackage)continue;
|
|
|
- $owner = $dataHandlerService->getKeyValue(['code'=>$actAllocationDetail->customerid],$owner_code_map);
|
|
|
- if(!$owner)continue;
|
|
|
- $commodity = $dataHandlerService->getKeyValue(['owner_id'=>$owner->id,'sku'=>$actAllocationDetail->sku],$commodity_owner_id_sku_map);
|
|
|
- if(!$commodity)continue;
|
|
|
- $params[] = [
|
|
|
- 'commodity_id' =>$commodity->id,
|
|
|
- 'order_package_id' =>$orderPackage->id,
|
|
|
- 'amount' => $actAllocationDetail->qty_each,
|
|
|
- 'created_at' => $create_at
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- unset($details,$order_packages_logistic_number_map,$owner_code_map,$commodity_owner_id_sku_map,$logistic_numbers);
|
|
|
- return $params;
|
|
|
- }
|
|
|
+// public function getParamsByActAllocationDetails($details,array $order_packages_logistic_number_map,array $owner_code_map,array $commodity_owner_id_sku_map,array $logistic_numbers){
|
|
|
+// /** @var DataHandlerService $dataHandlerService */
|
|
|
+// $dataHandlerService = app(DataHandlerService::class);
|
|
|
+// if(!$details)return [];
|
|
|
+// $params = [];
|
|
|
+// $create_at = Carbon::now()->format('Y-m-d H:i:s');
|
|
|
+// $updated_at = Carbon::now()->format('Y-m-d H:i:s');
|
|
|
+// foreach ($details as $actAllocationDetail) {
|
|
|
+// $pickToTraceID = $actAllocationDetail->picktotraceid;
|
|
|
+// if(in_array($pickToTraceID,$logistic_numbers)){
|
|
|
+// $orderPackage = $dataHandlerService->getKeyValue(['logistic_number'=>$pickToTraceID],$order_packages_logistic_number_map);
|
|
|
+// if(!$orderPackage)continue;
|
|
|
+// $owner = $dataHandlerService->getKeyValue(['code'=>$actAllocationDetail->customerid],$owner_code_map);
|
|
|
+// if(!$owner)continue;
|
|
|
+// $commodity = $dataHandlerService->getKeyValue(['owner_id'=>$owner->id,'sku'=>$actAllocationDetail->sku],$commodity_owner_id_sku_map);
|
|
|
+// if(!$commodity)continue;
|
|
|
+// $params[] = [
|
|
|
+// 'commodity_id' =>$commodity->id,
|
|
|
+// 'order_package_id' =>$orderPackage->id,
|
|
|
+// 'amount' => $actAllocationDetail->qty_each,
|
|
|
+// 'created_at' => $create_at
|
|
|
+// ];
|
|
|
+// }
|
|
|
+// }
|
|
|
+// unset($details,$order_packages_logistic_number_map,$owner_code_map,$commodity_owner_id_sku_map,$logistic_numbers);
|
|
|
+// return $params;
|
|
|
+// }
|
|
|
|
|
|
public function create(array $params){
|
|
|
if(!$params){return [];}
|
|
|
@@ -244,97 +201,6 @@ class OrderPackageCommoditiesService
|
|
|
public function updateByWmsOrder($orderHeaders){
|
|
|
if(!$orderHeaders){return ;}
|
|
|
$this->更新OPC_根据WMS订单($orderHeaders);
|
|
|
-// /** @var DataHandlerService $dataHandlerService*/
|
|
|
-// $dataHandlerService = app(DataHandlerService::class);
|
|
|
-// $commodities = app(CommodityService::class)->getByWmsOrders($orderHeaders);
|
|
|
-// $owners = app(OwnerService::class)->getByWmsOrders($orderHeaders);
|
|
|
-// $owners_id_map = $dataHandlerService->dataHeader(['id'],$owners);
|
|
|
-// $owner_code_map = $dataHandlerService->dataHeader(['code'],$owners);
|
|
|
-// $commodity_owner_id_sku_map = $dataHandlerService->dataHeader(['owner_id','sku'],$commodities);
|
|
|
-//
|
|
|
-// $commodities_owner_code_code_map = [];
|
|
|
-// foreach ($commodities as $commodity) {
|
|
|
-// $owner = $dataHandlerService->getKeyValue(['id'=>$commodity->owner_id],$owners_id_map);
|
|
|
-// $commodities_owner_code_code_map[' owner_code='.$owner->code.' code='.$commodity->code] = $commodity;
|
|
|
-// }
|
|
|
-//
|
|
|
-// $order_nos = data_get($orderHeaders,'*.orderno');
|
|
|
-// $order_package_commodities = OrderPackageCommodities::query()->with('package.order','commodity')
|
|
|
-// ->whereHas('package.order',function($query) use ($order_nos){
|
|
|
-// $query->whereIn('code',$order_nos);
|
|
|
-// })->get();
|
|
|
-//
|
|
|
-// $order_packages = OrderPackage::query()->with('order')->whereHas('order',function($query) use ($order_nos){
|
|
|
-// $query->whereIn('code',$order_nos);
|
|
|
-// })->get();
|
|
|
-//
|
|
|
-// $order_package_logistic_numbers_map = $dataHandlerService->dataHeader(['logistic_number'],$order_packages);
|
|
|
-// $order_no_map = [];
|
|
|
-// foreach ($order_package_commodities as $order_package_commodity) {
|
|
|
-// $order = $order_package_commodity->package->order;
|
|
|
-// $order_no_map[$order->code][] = $order_package_commodity;
|
|
|
-// }
|
|
|
-//
|
|
|
-// $insertParams = [];
|
|
|
-// $updateParams = [['id','order_package_id'.'commodity_id','amount','updated_at']];
|
|
|
-// $updated_at = Carbon::now()->toDateTimeString();
|
|
|
-// $created_at = Carbon::now()->toDateTimeString();
|
|
|
-// foreach ($orderHeaders as $orderHeader) {
|
|
|
-// $order_package_commodities = $order_no_map[$orderHeader->orderno] ?? false;
|
|
|
-// $actAllocationDetails = $orderHeader->actAllocationDetails;
|
|
|
-// $logistic_numbers = array_unique(array_diff(data_get($actAllocationDetails,'*.picktotraceid'),['','*',null])) ;
|
|
|
-// if(!$order_package_commodities){
|
|
|
-// $params = $this->getParamsByActAllocationDetails($actAllocationDetails,$order_package_logistic_numbers_map, $owner_code_map, $commodity_owner_id_sku_map, $logistic_numbers);
|
|
|
-// foreach ($params as $param) {
|
|
|
-// $insertParams[] = $param;
|
|
|
-// }
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// if($actAllocationDetails->count() > count($order_package_commodities)){
|
|
|
-// $deleteKey = [];
|
|
|
-// foreach ($actAllocationDetails as $key1=>$actAllocationDetail) {
|
|
|
-// foreach ( $order_package_commodities as $key=>$item) {
|
|
|
-// $commodity = $item->commodity;
|
|
|
-// if($actAllocationDetail->sku == $commodity->sku && $item->amount == $actAllocationDetail->qty_each){
|
|
|
-// unset($order_package_commodities[$key]);
|
|
|
-// unset($actAllocationDetails[$key1]);
|
|
|
-// $deleteKey[] = $key1;
|
|
|
-// break;
|
|
|
-// }else if($item ->sku == $commodity->sku && $item->amount != $actAllocationDetail->qty_each){
|
|
|
-// $updateParams[] = [
|
|
|
-// 'id' => $item->id,
|
|
|
-// 'commodity_id' => $commodity->id,
|
|
|
-// 'amount' => $actAllocationDetail->qty_each,
|
|
|
-// 'updated_at' => $updated_at
|
|
|
-// ];
|
|
|
-// $deleteKey[] = $key1;
|
|
|
-// unset($actAllocationDetails[$key1]);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// $actAllocationDetails =$actAllocationDetails->filter(function ($value, $key) use($deleteKey) {
|
|
|
-// return !in_array($key, $deleteKey);
|
|
|
-// });
|
|
|
-// $params = $this->getParamsByActAllocationDetails($actAllocationDetails,$order_package_logistic_numbers_map, $owner_code_map, $commodity_owner_id_sku_map, $logistic_numbers);
|
|
|
-// foreach ($params as $param) {
|
|
|
-// $insertParams[] = $param;
|
|
|
-// }
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(count($updateParams) > 0){
|
|
|
-// $this->batchUpdate($updateParams);
|
|
|
-// }
|
|
|
-//
|
|
|
-// if(count($insertParams) > 0){
|
|
|
-// try {
|
|
|
-// $this->insert($insertParams);
|
|
|
-// LogService::log(__METHOD__,__FUNCTION__,'批量添加 OrderPackageCommodities '. count($insertParams) .json_encode($insertParams));
|
|
|
-// } catch (\Exception $e) {
|
|
|
-// LogService::log(__METHOD__,__FUNCTION__,'批量添加 OrderPackageCommodities error'.json_encode($insertParams)."||".$e->getMessage().'||'.$e->getTraceAsString());
|
|
|
-// }
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
public function getByWmsOrder($orderHeaders){
|