|
@@ -397,22 +397,28 @@ class BoxService extends Service
|
|
|
{
|
|
|
list($status, $data) = self::$box_hook->boxDetail($data);
|
|
|
if (!$status) return [false, $data];
|
|
|
- $sale_orders_product_ids = [];
|
|
|
+ $return = [];
|
|
|
foreach ($data as $v){
|
|
|
- $sale_orders_product_ids[] = $v['top_id'];
|
|
|
+ $key = $v['ext_1'] . $v['ext_3'];
|
|
|
+ if(! isset($return[$key])){
|
|
|
+ $return[$key] = $v;
|
|
|
+ }else{
|
|
|
+ $return[$key]['num'] += $v['num'];
|
|
|
+ }
|
|
|
}
|
|
|
+ $sale_orders_product_ids = array_unique(array_column($data,'top_id'));
|
|
|
$list = SaleOrdersProduct::wherein('id',$sale_orders_product_ids)->get()->toArray();
|
|
|
$key_list = [];
|
|
|
foreach ($list as $v){
|
|
|
$key_list[$v['id']] = $v;
|
|
|
}
|
|
|
|
|
|
- foreach ($data as &$v){
|
|
|
+ foreach ($return as &$v){
|
|
|
$detail = $key_list[$v['top_id']];
|
|
|
$v['customer_no'] = $detail['customer_no'];
|
|
|
$v['customer_name'] = $detail['customer_name'];
|
|
|
}
|
|
|
- return [true, $data];
|
|
|
+ return [true, array_values($return)];
|
|
|
}
|
|
|
|
|
|
public function boxProductList($data){
|