|
@@ -4,6 +4,7 @@ namespace App\Service;
|
|
|
|
|
|
use App\Model\Orders;
|
|
|
use App\Model\SaleOrdersProduct;
|
|
|
+use App\Model\SaleOrdersProductStockDetail;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
class FyyOrderService extends Service
|
|
@@ -52,11 +53,18 @@ class FyyOrderService extends Service
|
|
|
$return[$key]['crt_id'] = $user['id'];
|
|
|
$return[$key]['crt_time'] = time();
|
|
|
|
|
|
-// $keys = $order_no . ($value['technology_name'] ?? '' ) . ;
|
|
|
+ $keys = ($value['technology_name'] ?? '' ) . ($value['wood_name'] ?? '' ) . $value['product_no'];
|
|
|
+ $return_stock_detail_map[$keys] = $order_no;
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($return_stock_detail as $key => $value){
|
|
|
+ $keys = ($value['technology_name'] ?? '' ) . ($value['wood_name'] ?? '' ) . $value['product_no'];
|
|
|
+ $return_stock_detail[$key]['order_no'] = $return_stock_detail_map[$keys] ?? '';
|
|
|
}
|
|
|
|
|
|
Orders::insert($orders);
|
|
|
SaleOrdersProduct::insert($return);
|
|
|
+ SaleOrdersProductStockDetail::insert($return_stock_detail);
|
|
|
|
|
|
DB::commit();
|
|
|
}catch (\Exception $e){
|
|
@@ -108,19 +116,42 @@ class FyyOrderService extends Service
|
|
|
if(isset($data['status'])) $model->where('status',$data['status']);
|
|
|
|
|
|
$list = $this->limit($model,'',$data);
|
|
|
+ $list = $this->fillData($list);
|
|
|
|
|
|
return [true, $list];
|
|
|
}
|
|
|
|
|
|
+ public function fillData($data){
|
|
|
+ if(empty($data['data'])) return $data;
|
|
|
+
|
|
|
+ $order_no = array_filter(array_column($data['data'],'order_no'));
|
|
|
+ $detail = SaleOrdersProductStockDetail::where('del_time',0)
|
|
|
+ ->whereIn('order_no',$order_no)
|
|
|
+ ->select('order_no','product_no','product_quantity_on_hand','technology_name','wood_name','warehouse_name')
|
|
|
+ ->get()->toArray();
|
|
|
+ $detail_map = [];
|
|
|
+ foreach ($detail as $value){
|
|
|
+ $keys = $value['order_no'] . $value['product_no'];
|
|
|
+ $detail_map[$keys][] = [
|
|
|
+ 'warehouse_name' => $value['warehouse_name'],
|
|
|
+ 'product_quantity_on_hand' => $value['product_quantity_on_hand']
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($data['data'] as $key => $value){
|
|
|
+ $keys = $value['order_no'] . $value['product_no'];
|
|
|
+ $data['data'][$key]['sub'] = $detail_map[$keys] ?? [];
|
|
|
+ }
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
public function orderRule($data){
|
|
|
$result = Orders::where('del_time',0)
|
|
|
->whereIn('out_order_no',array_column($data,'out_order_no'))
|
|
|
->select('out_order_no')
|
|
|
->get()->toArray();
|
|
|
- if(! empty($result)){
|
|
|
- $out_order_no_exists = array_column($result,'out_order_no');
|
|
|
- return [false,'下列销售订单号已存在:'. implode(',',$out_order_no_exists)];
|
|
|
- }
|
|
|
+ if(! empty($result)) return [false,'查询区间内销售订单号已存在'];
|
|
|
|
|
|
return [true,''];
|
|
|
}
|