|
|
@@ -68,12 +68,14 @@ Class OrderCommodityService
|
|
|
$this->filterHasExist($ActAllocationDetail_maps,$orderCommodity_maps);
|
|
|
$create_params = $this->getCreateParams($ActAllocationDetail_maps,$orderCommodity_maps);
|
|
|
$inner_params = $this->getInnerParamsByParams($create_params,$order_code_map,$commodity_map);
|
|
|
- if(count($inner_params)>0){
|
|
|
+
|
|
|
+ if(count($inner_params)>0){
|
|
|
$inner_params = array_chunk($inner_params,4000);
|
|
|
foreach ($inner_params as $inner_param) {
|
|
|
$this->insert($inner_param);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if(count($delete_ids)==0)return;
|
|
|
OrderCommodity::query()->whereIn('id',$delete_ids)->delete();
|
|
|
app('LogService')->log(__METHOD__,__FUNCTION__,"delete OrderCommodity ".json_encode($delete_ids));
|
|
|
@@ -86,7 +88,7 @@ Class OrderCommodityService
|
|
|
if($orderHeaders->count()==0) return $map;
|
|
|
$orderHeaders->each(function($orderHeader)use(&$map){
|
|
|
$orderHeader->actAllocationDetails->each(function ($details)use(&$map){
|
|
|
- $key = "order_{$details['orderno']}_owner_code_{$details['customerid']}_sku_{$details['sku']}_location_{$details['location']}";
|
|
|
+ $key = "order_{$details['orderno']}_owner_code_{$details['customerid']}_sku_{$details['sku']}_location_{$details['location']}_amount_{$details['qty_each']}";
|
|
|
if(empty($map[$key]))$map[$key]=[];
|
|
|
$map[$key][] = [
|
|
|
'code' => $details['orderno'],
|
|
|
@@ -103,7 +105,13 @@ Class OrderCommodityService
|
|
|
public function filterHasExist(&$ActAllocationDetail_maps,&$orderCommodity_maps)
|
|
|
{
|
|
|
foreach ($ActAllocationDetail_maps as $key=>$actAllocationDetail_map) {
|
|
|
- if(isset($orderCommodity_maps[$key]))unset($ActAllocationDetail_maps[$key]);
|
|
|
+ $orderCommodity_map = $orderCommodity_maps[$key] ?? null;
|
|
|
+ if($orderCommodity_map == null)continue;
|
|
|
+ foreach ($actAllocationDetail_map as $index=>$item) {
|
|
|
+ if(count($orderCommodity_map)==0)break;
|
|
|
+ array_shift($orderCommodity_map);
|
|
|
+ unset($actAllocationDetail_map[$index]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// TODO 将传入OrderCommodities 重组为符合当前基准的数组
|
|
|
@@ -116,7 +124,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}_amount_{$orderCommodity->amount}";
|
|
|
if(empty($map[$key]))$map[$key]=[];
|
|
|
$map[$key][] =[
|
|
|
'id' => $orderCommodity->id,
|
|
|
@@ -135,13 +143,17 @@ Class OrderCommodityService
|
|
|
$ids = [];
|
|
|
if(count($orderCommodity_maps)==0)return $ids;
|
|
|
foreach ($orderCommodity_maps as $key=>$orderCommodity_map) {
|
|
|
- if(isset($ActAllocationDetail_maps[$key]))continue;
|
|
|
- foreach ($orderCommodity_map as $key1=>$orderCommodity) {
|
|
|
- $ids[] = $orderCommodity['id'];
|
|
|
- unset($orderCommodity_map[$key1]);
|
|
|
+ if(array_key_exists($key,$orderCommodity_maps))continue;
|
|
|
+ $ActAllocationDetail_map = $ActAllocationDetail_maps[$key];
|
|
|
+ if(count($ActAllocationDetail_map) == count($orderCommodity_map))continue;
|
|
|
+ if(count($ActAllocationDetail_map) < count($orderCommodity_map)){
|
|
|
+ foreach ($orderCommodity_map as $index=>$item) {
|
|
|
+ if(count($ActAllocationDetail_map) == 0)$ids[] =$item['id'];
|
|
|
+ array_shift($ActAllocationDetail_map);
|
|
|
+ unset($orderCommodity_map[$index]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return $ids;
|
|
|
}
|
|
|
// TODO 返回创建的数组
|
|
|
@@ -149,9 +161,21 @@ Class OrderCommodityService
|
|
|
{
|
|
|
$params = [];
|
|
|
foreach ($ActAllocationDetail_maps as $key=>$actAllocationDetail_map) {
|
|
|
- if(isset($orderCommodity_maps[$key]))continue;
|
|
|
- foreach ($actAllocationDetail_map as $actAllocationDetail) {
|
|
|
- $params[] = $actAllocationDetail;
|
|
|
+ $orderCommodity_map = $orderCommodity_maps[$key] ?? null;
|
|
|
+ if($orderCommodity_map == null){
|
|
|
+ foreach ($actAllocationDetail_map as $index=>$actAllocationDetail) {
|
|
|
+ $params[] = $actAllocationDetail;
|
|
|
+ unset($actAllocationDetail_map[$key]);
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }elseif(count($actAllocationDetail_map) == count($orderCommodity_map)){
|
|
|
+ continue;
|
|
|
+ }elseif(count($actAllocationDetail_map) > count($orderCommodity_map)){
|
|
|
+ foreach ($actAllocationDetail_map as $index=>$item) {
|
|
|
+ if(count($orderCommodity_map) == 0)$params[] = $item;
|
|
|
+ array_shift($orderCommodity_map);
|
|
|
+ unset($actAllocationDetail_map[$key]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return $params;
|