|
|
@@ -35,40 +35,40 @@ Class OrderCommodityService
|
|
|
$ownerService = app('OwnerService');
|
|
|
$commodityService = app('CommodityService');
|
|
|
$dataHandlerService = app('DataHandlerService');
|
|
|
- $orderNos = data_get($orderHeaders,'*.code');
|
|
|
- $map = [];$owner_codes = [];
|
|
|
+ $orderNos = data_get($orderHeaders,'*.orderno');
|
|
|
+ $owner_codes = [];$sku_codes = [];
|
|
|
+ $count = 0;
|
|
|
foreach ($orderHeaders as $orderHeader) {
|
|
|
$actAllocationDetails = $orderHeader->actAllocationDetails;
|
|
|
foreach ($actAllocationDetails as $actAllocationDetail) {
|
|
|
- $key = "owner_code_{$actAllocationDetail['customerid']}_'sku'";
|
|
|
$owner_codes[$actAllocationDetail['customerid']] = $actAllocationDetail['customerid'];
|
|
|
- $map[$key] = [
|
|
|
- 'owner_code'=>$actAllocationDetail['customerid'],
|
|
|
- 'sku'=>$actAllocationDetail['sku']
|
|
|
- ];
|
|
|
+ $sku_codes[$actAllocationDetail['sku']] = $actAllocationDetail['sku'];
|
|
|
+ $count++;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
$owners = $ownerService->getOwnerByCodes($owner_codes);
|
|
|
$owner_id_maps = $dataHandlerService->dataHeader(['id'],$owners);
|
|
|
- $commodities = $commodityService->getParamsByBasSku($map);
|
|
|
+ $commodities = $commodityService->get_(data_get($owners,'*.id'),$sku_codes,[],true);
|
|
|
+
|
|
|
$commodity_map = [];
|
|
|
foreach ($commodities as $commodity) {
|
|
|
- $owner = $dataHandlerService->getKeyValue(['id'=>$commodity->id],$owner_map);
|
|
|
+ $owner = $dataHandlerService->getKeyValue(['id'=>$commodity->owner_id],$owner_id_maps);
|
|
|
$key = "_owner_code_{$owner['code']}_sku_{$commodity['sku']}";
|
|
|
$commodity_map[$key] = $commodity;
|
|
|
}
|
|
|
|
|
|
- $orderCommodities = OrderCommodity::query()->with('order')->whereHas('order',function ($qurey)use($orderNos){
|
|
|
- $qurey->whereIn('code',$orderNos);
|
|
|
+ $orderCommodities = OrderCommodity::query()->with(['order','commodity'])->whereHas('order',function ($query)use($orderNos){
|
|
|
+ $query->whereIn('code',$orderNos);
|
|
|
})->get();
|
|
|
$orders = Order::query()->whereIn('code',$orderNos)->get();
|
|
|
$order_code_map = $dataHandlerService->dataHeader(['code'],$orders);
|
|
|
$ActAllocationDetail_maps = $this->getRegroupActAllocationDetails($orderHeaders);
|
|
|
$orderCommodity_maps = $this->getRegroupOrderCommodities($orderCommodities,$owner_id_maps);
|
|
|
|
|
|
+ $delete_ids = $this->getDeleteIds($ActAllocationDetail_maps,$orderCommodity_maps);
|
|
|
$this->filterHasExist($ActAllocationDetail_maps,$orderCommodity_maps);
|
|
|
$create_params = $this->getCreateParams($ActAllocationDetail_maps,$orderCommodity_maps);
|
|
|
- $delete_ids = $this->getDeleteIds($ActAllocationDetail_maps,$orderCommodity_maps);
|
|
|
$inner_params = $this->getInnerParamsByParams($create_params,$order_code_map,$commodity_map);
|
|
|
if(count($inner_params)>0){
|
|
|
$inner_params = array_chunk($inner_params,4000);
|
|
|
@@ -118,7 +118,7 @@ Class OrderCommodityService
|
|
|
$orderCommodities->each(function($orderCommodity)use(&$map,$owner_id_maps,$dataHandlerService){
|
|
|
$order = $orderCommodity->order;
|
|
|
$owner = $dataHandlerService->getKeyValue(['id'=>$order->owner_id ?? ''],$owner_id_maps);
|
|
|
- $key = "order_{($order->code ?? '')}_owner_code_{($owner->code)}_sku_{($orderCommodity->commodity->sku ?? '')}_location_{($orderCommodity->location)}";
|
|
|
+ $key = "order_{$order->code}_owner_code_{$owner->code}_sku_{$orderCommodity->commodity->sku}_location_{$orderCommodity->location}";
|
|
|
if(empty($map[$key]))$map[$key]=[];
|
|
|
$map[$key][] =[
|
|
|
'id' => $orderCommodity->id,
|
|
|
@@ -142,6 +142,7 @@ Class OrderCommodityService
|
|
|
unset($orderCommodity_map[$key1]);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return $ids;
|
|
|
}
|
|
|
// TODO 返回创建的数组
|
|
|
@@ -149,7 +150,7 @@ Class OrderCommodityService
|
|
|
{
|
|
|
$params = [];
|
|
|
foreach ($ActAllocationDetail_maps as $key=>$actAllocationDetail_map) {
|
|
|
- if(empty($orderCommodity_maps[$key]))continue;
|
|
|
+ if(isset($orderCommodity_maps[$key]))continue;
|
|
|
foreach ($actAllocationDetail_map as $actAllocationDetail) {
|
|
|
$params[] = $actAllocationDetail;
|
|
|
}
|