|
@@ -65,19 +65,19 @@ class ExportFileService extends Service
|
|
|
|
|
|
//导出文件方法
|
|
|
protected static $fuc = [
|
|
|
- self::type_one => 'one',
|
|
|
- self::type_two => 'two',
|
|
|
- self::type_three => 'three',
|
|
|
- self::type_four => 'four',
|
|
|
- self::type_five => 'five',
|
|
|
+ self::type_one => 'kqList',
|
|
|
+ self::type_two => '',
|
|
|
+ self::type_three => '',
|
|
|
+ self::type_four => '',
|
|
|
+ self::type_five => '',
|
|
|
];
|
|
|
|
|
|
protected static $fuc_name = [
|
|
|
- self::type_one => '合同订单',
|
|
|
- self::type_two => '派工订单',
|
|
|
- self::type_three => '收付款单',
|
|
|
- self::type_four => '施工单',
|
|
|
- self::type_five => '采购单',
|
|
|
+ self::type_one => '考勤',
|
|
|
+ self::type_two => '',
|
|
|
+ self::type_three => '',
|
|
|
+ self::type_four => '',
|
|
|
+ self::type_five => '',
|
|
|
];
|
|
|
|
|
|
public static $filename = "";
|
|
@@ -98,652 +98,25 @@ class ExportFileService extends Service
|
|
|
return [true, $return];
|
|
|
}
|
|
|
|
|
|
- public function one($ergs){
|
|
|
+ public function kqList($ergs){
|
|
|
$id = $ergs['id'];
|
|
|
|
|
|
// 导出数据
|
|
|
$return = [];
|
|
|
|
|
|
- DB::table('sales_order')
|
|
|
+ DB::table('kq_list')
|
|
|
->whereIn('id', $id)
|
|
|
->select('id','order_number','model_type','sales_order_type','sign_time','plat_order','plat_type','product_total','other_fee','discount_fee','contract_fee','crt_time','crt_id','state','invoice_state','pay_way')
|
|
|
->orderBy('id','desc')
|
|
|
->chunk(500,function ($data) use(&$return){
|
|
|
- $data = $data->toArray();
|
|
|
- $data_id = array_unique(array_column($data,'id'));
|
|
|
- $emp_map = Employee::whereIn('id',array_unique(array_column($data,'crt_id')))
|
|
|
- ->pluck('emp_name','id')
|
|
|
- ->toArray();
|
|
|
- //获取分社订货合同关联的发货单
|
|
|
- $id = [];
|
|
|
- foreach ($data as $value){
|
|
|
- $id[] = [
|
|
|
- 'id' => $value->id,
|
|
|
- 'invoice_state' => $value->invoice_state,
|
|
|
- ];
|
|
|
- }
|
|
|
- $invoiceData = (new SalesOrderService())->getInvoiceOrderData($id);
|
|
|
+ $data = Collect($data)->map(function ($object) {
|
|
|
+ return (array)$object;
|
|
|
+ })->toArray();
|
|
|
|
|
|
- $array = array_unique(array_merge_recursive(array_column($data,'car_type'),array_column($data,'pay_way'),array_column($data,'install_position'),array_column($data,'install_method'),array_column($data,'plat_type')));
|
|
|
- $basic_map = BasicType::whereIn('id',$array)
|
|
|
- ->pluck('title','id')
|
|
|
- ->toArray();
|
|
|
-
|
|
|
- $product = [];
|
|
|
- $sales_p_info = SalesOrderProductInfo::where('del_time',0)
|
|
|
- ->whereIn('sales_order_id',$data_id)
|
|
|
- ->get()->toArray();
|
|
|
- $basic_price = BasicType::whereIn('id',array_unique(array_column($sales_p_info,'basic_type_id')))->pluck('title','id')->toArray();
|
|
|
- $map = (new ProductService())->getProductDetail(array_column($sales_p_info,'product_id'));
|
|
|
- foreach ($sales_p_info as $value){
|
|
|
- $tmp = $map[$value['product_id']] ?? [];
|
|
|
- $value['title'] = $tmp['title'] ?? "";
|
|
|
- $value['code'] = $tmp['code'] ?? "";
|
|
|
- $value['size'] = $tmp['size'] ?? "";
|
|
|
- $value['bar_code'] = $tmp['bar_code'] ?? "";
|
|
|
- $value['basic_type_title'] = $basic_price[$value['basic_type_id']] ?? "";
|
|
|
- $value['install_time'] = $tmp['install_time'] ?? 0;
|
|
|
- $product[$value['sales_order_id']][] = $value;
|
|
|
- }
|
|
|
-
|
|
|
- //金额
|
|
|
- list($for_amount_list, $for_amount_list1) = (new PaymentReceiptService())->getPaymentReceiptDataCountList(array_column($data,'order_number'));
|
|
|
- list($getDifferentAmountALL,$getDifferentAmountALL1) = (new ReturnExchangeOrderService())->getDifferentAmountALLNew(array_column($data,'id'));
|
|
|
-
|
|
|
- $flag = [];
|
|
|
- foreach ($data as $value){
|
|
|
- $tmp = $invoiceData[$value->id] ?? [];
|
|
|
- $invoice_arr = implode(',', $tmp);
|
|
|
- $model_type_title = SalesOrder::$model_type_title[$value->model_type] ?? '';
|
|
|
- $plat_type_title = $basic_map[$value->plat_type] ?? '';
|
|
|
- $sales_order_type_title = SalesOrder::$order_type[$value->sales_order_type] ?? '';
|
|
|
- $crt_time = empty($value->crt_time) ? '' : date('Y-m-d',$value->crt_time);
|
|
|
- $sign_time = empty($value->sign_time) ? '' : date('Y-m-d',$value->sign_time);
|
|
|
- $product_tmp = $product[$value->id] ?? [];
|
|
|
- if($value->sales_order_type == SalesOrder::Order_type_one){
|
|
|
- $state = SalesOrder::$state[$value->state] ?? '';
|
|
|
- }else{
|
|
|
- $state = SalesOrder::$state2[$value->state] ?? '';
|
|
|
- }
|
|
|
-
|
|
|
- foreach ($product_tmp as $val){
|
|
|
- if(in_array($val['sales_order_id'], $flag)){
|
|
|
- $return[] = [
|
|
|
- 'order_number' => "",
|
|
|
- 'model_type_title' => "",
|
|
|
- 'sales_order_type_title' => "",
|
|
|
- 'sign_time' => "",
|
|
|
- 'plat_order' => "",
|
|
|
- 'plat_type_title' => "",
|
|
|
- 'product_total' => "",
|
|
|
- 'other_fee' => "",
|
|
|
- 'discount_fee' => "",
|
|
|
- 'contract_fee' => "",
|
|
|
- 'fee1' => "",
|
|
|
- 'fee2' => "",
|
|
|
- 'fee3' => "",
|
|
|
- 'fee4' => "",
|
|
|
- 'crt_time' => "",
|
|
|
- 'crt_name' => "",
|
|
|
- 'state_title' => "",
|
|
|
- 'invoice_state_title' =>"",
|
|
|
- 'invoice_arr' => "",
|
|
|
- 'pay_way' => "",
|
|
|
- 'product_title' => $val['title'],
|
|
|
- 'product_code' => $val['code'],
|
|
|
- 'product_size' => $val['size'],
|
|
|
- 'product_rate' => $val['rate'],
|
|
|
- 'product_price' => $val['price'],
|
|
|
- 'product_num' => $val['number'],
|
|
|
- 'product_final_amount' => $val['final_amount'],
|
|
|
- ];
|
|
|
- }else{
|
|
|
- $flag[] = $val['sales_order_id'];
|
|
|
-
|
|
|
- //(审核后)
|
|
|
- //已收
|
|
|
- $one = $for_amount_list1[$value->order_number . PaymentReceipt::type_one] ?? 0;
|
|
|
- $red = $for_amount_list1[$value->order_number . PaymentReceipt::type_three] ?? 0;
|
|
|
- $return_exchange_amount1 = $getDifferentAmountALL1[$value->id] ?? 0;
|
|
|
- $bad = bcsub($return_exchange_amount1 ,$red,2);
|
|
|
- //已收金额
|
|
|
- $fee1 = bcsub($one ,$red,2);
|
|
|
- //未收金额
|
|
|
- $fee2 = bcsub(bcsub(bcsub($value->contract_fee, $fee1,2), $bad, 2),$red,2);
|
|
|
- //红冲金额
|
|
|
- $fee3 = $red;
|
|
|
- //坏账金额
|
|
|
- $fee4 = $bad;
|
|
|
-
|
|
|
- $return[] = [
|
|
|
- 'order_number' => $value->order_number,
|
|
|
- 'model_type_title' => $model_type_title,
|
|
|
- 'sales_order_type_title' => $sales_order_type_title,
|
|
|
- 'sign_time' => $sign_time,
|
|
|
- 'plat_order' => $value->plat_order,
|
|
|
- 'plat_type_title' => $plat_type_title,
|
|
|
- 'product_total' => $value->product_total,
|
|
|
- 'other_fee' => $value->other_fee,
|
|
|
- 'discount_fee' => $value->discount_fee,
|
|
|
- 'contract_fee' => $value->contract_fee,
|
|
|
- 'fee1' => $fee1,
|
|
|
- 'fee2' => $fee2,
|
|
|
- 'fee3' => $fee3,
|
|
|
- 'fee4' => $fee4,
|
|
|
- 'crt_time' => $crt_time,
|
|
|
- 'crt_name' => $emp_map[$value->crt_id] ?? "",
|
|
|
- 'state_title' => $state,
|
|
|
- 'invoice_state_title' => SalesOrder::$invoice_state[$value->invoice_state] ?? '',
|
|
|
- 'invoice_arr' => $invoice_arr,
|
|
|
- 'pay_way' => $basic_map[$value->pay_way] ?? "",
|
|
|
- 'product_title' => $val['title'],
|
|
|
- 'product_code' => $val['code'],
|
|
|
- 'product_size' => $val['size'],
|
|
|
- 'product_rate' => $val['rate'],
|
|
|
- 'product_price' => $val['price'],
|
|
|
- 'product_num' => $val['number'],
|
|
|
- 'product_final_amount' => $val['final_amount'],
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- $header = ['合同单号','销售类型','产品类型','签订时间','平台单号','平台类型','产品合计','其他费用','优惠金额','合同金额','已收金额','未收金额','红冲金额','坏账金额','创建时间','创建人','订单状态','发货状态','发货单号','付款方式','产品名称','产品编码','产品规格','产品税率','产品单价','产品数量','产品合同金额'];
|
|
|
-
|
|
|
- return $this->saveExportData($return,$header);
|
|
|
- }
|
|
|
-
|
|
|
- public function two($ergs){
|
|
|
- $id = $ergs['id'];
|
|
|
-
|
|
|
- // 导出数据
|
|
|
- $return = [];
|
|
|
-
|
|
|
- DB::table('sales_order')
|
|
|
- ->whereIn('id', $id)
|
|
|
- ->select('id','order_number','model_type','sales_order_type','sign_time','plat_order','plat_type','product_total','other_fee','discount_fee','contract_fee','crt_time','crt_id','state','invoice_state','pay_way')
|
|
|
- ->orderBy('id','desc')
|
|
|
- ->chunk(500,function ($data) use(&$return){
|
|
|
- $data = $data->toArray();
|
|
|
- $data_id = array_unique(array_column($data,'id'));
|
|
|
- $emp_map = Employee::whereIn('id',array_unique(array_column($data,'crt_id')))
|
|
|
- ->pluck('emp_name','id')
|
|
|
- ->toArray();
|
|
|
- //获取分社订货合同关联的发货单
|
|
|
- $id = [];
|
|
|
- foreach ($data as $value){
|
|
|
- $id[] = [
|
|
|
- 'id' => $value->id,
|
|
|
- 'invoice_state' => $value->invoice_state,
|
|
|
- 'state' => $value->state,
|
|
|
- ];
|
|
|
- }
|
|
|
- $invoiceData = (new SalesOrderService())->getInvoiceOrderData($id);
|
|
|
-
|
|
|
- $array = array_unique(array_merge_recursive(array_column($data,'car_type'),array_column($data,'pay_way'),array_column($data,'install_position'),array_column($data,'install_method'),array_column($data,'plat_type')));
|
|
|
- $basic_map = BasicType::whereIn('id',$array)
|
|
|
- ->pluck('title','id')
|
|
|
- ->toArray();
|
|
|
-
|
|
|
- $product = [];
|
|
|
- $sales_p_info = SalesOrderProductInfo::where('del_time',0)
|
|
|
- ->whereIn('sales_order_id',$data_id)
|
|
|
- ->get()->toArray();
|
|
|
- $basic_price = BasicType::whereIn('id',array_unique(array_column($sales_p_info,'basic_type_id')))->pluck('title','id')->toArray();
|
|
|
- $map = (new ProductService())->getProductDetail(array_column($sales_p_info,'product_id'));
|
|
|
-
|
|
|
- //指派金额
|
|
|
- $fee = [];
|
|
|
- $sales_o_info = SalesOrderOtherFee::where('del_time',0)
|
|
|
- ->whereIn('sales_order_id',$data_id)
|
|
|
- ->get()->toArray();
|
|
|
- foreach ($sales_o_info as $value){
|
|
|
- $fee[$value['sales_order_id']] = $value['other_fee_1'];
|
|
|
- }
|
|
|
- foreach ($sales_p_info as $value){
|
|
|
- $tmp = $map[$value['product_id']] ?? [];
|
|
|
- $value['title'] = $tmp['title'] ?? "";
|
|
|
- $value['code'] = $tmp['code'] ?? "";
|
|
|
- $value['size'] = $tmp['size'] ?? "";
|
|
|
- $value['bar_code'] = $tmp['bar_code'] ?? "";
|
|
|
- $value['basic_type_title'] = $basic_price[$value['basic_type_id']] ?? "";
|
|
|
- $value['install_time'] = $tmp['install_time'] ?? 0;
|
|
|
- $product[$value['sales_order_id']][] = $value;
|
|
|
- }
|
|
|
-
|
|
|
- //分派的总社或分社
|
|
|
- $dispatch = (new SalesOrderService())->getDispatchData($id);
|
|
|
-
|
|
|
- //金额
|
|
|
- list($for_amount_list, $for_amount_list1) = (new PaymentReceiptService())->getPaymentReceiptDataCountList(array_column($data,'order_number'));
|
|
|
- list($getDifferentAmountALL,$getDifferentAmountALL1) = (new ReturnExchangeOrderService())->getDifferentAmountALLNew(array_column($data,'id'));
|
|
|
-
|
|
|
- $flag = [];
|
|
|
- foreach ($data as $value){
|
|
|
- $tmp = $invoiceData[$value->id] ?? [];
|
|
|
- $invoice_arr = implode(',', $tmp);
|
|
|
- $model_type_title = SalesOrder::$model_type_title[$value->model_type] ?? '';
|
|
|
- $plat_type_title = $basic_map[$value->plat_type] ?? '';
|
|
|
- $sales_order_type_title = SalesOrder::$order_type[$value->sales_order_type] ?? '';
|
|
|
- $crt_time = empty($value->crt_time) ? '' : date('Y-m-d',$value->crt_time);
|
|
|
- $sign_time = empty($value->sign_time) ? '' : date('Y-m-d',$value->sign_time);
|
|
|
- $product_tmp = $product[$value->id] ?? [];
|
|
|
- if($value->sales_order_type == SalesOrder::Order_type_one){
|
|
|
- $state = SalesOrder::$state[$value->state] ?? '';
|
|
|
- }else{
|
|
|
- $state = SalesOrder::$state2[$value->state] ?? '';
|
|
|
- }
|
|
|
-
|
|
|
- foreach ($product_tmp as $val){
|
|
|
- if(in_array($val['sales_order_id'], $flag)){
|
|
|
- $return[] = [
|
|
|
- 'order_number' => "",
|
|
|
- 'model_type_title' => "",
|
|
|
- 'sales_order_type_title' => "",
|
|
|
- 'sign_time' => "",
|
|
|
- 'plat_order' => "",
|
|
|
- 'plat_type_title' => "",
|
|
|
- 'product_total' => "",
|
|
|
- 'other_fee' => "",
|
|
|
- 'discount_fee' => "",
|
|
|
- 'contract_fee' => "",
|
|
|
- 'fee' => "",
|
|
|
- 'dispatch_company' => "",
|
|
|
- 'fee1' => "",
|
|
|
- 'fee2' => "",
|
|
|
- 'fee3' => "",
|
|
|
- 'fee4' => "",
|
|
|
- 'crt_time' => "",
|
|
|
- 'crt_name' => "",
|
|
|
- 'state_title' => "",
|
|
|
- 'invoice_state_title' =>"",
|
|
|
- 'invoice_arr' => "",
|
|
|
- 'pay_way' => "",
|
|
|
- 'product_title' => $val['title'],
|
|
|
- 'product_code' => $val['code'],
|
|
|
- 'product_size' => $val['size'],
|
|
|
- 'product_rate' => $val['rate'],
|
|
|
- 'product_price' => $val['price'],
|
|
|
- 'product_num' => $val['number'],
|
|
|
- 'product_final_amount' => $val['final_amount'],
|
|
|
- ];
|
|
|
- }else{
|
|
|
- $flag[] = $val['sales_order_id'];
|
|
|
-
|
|
|
- //(审核后)
|
|
|
- //已收
|
|
|
- $one = $for_amount_list1[$value->order_number . PaymentReceipt::type_one] ?? 0;
|
|
|
- $red = $for_amount_list1[$value->order_number . PaymentReceipt::type_three] ?? 0;
|
|
|
- $return_exchange_amount1 = $getDifferentAmountALL1[$value->id] ?? 0;
|
|
|
- $bad = bcsub($return_exchange_amount1 ,$red,2);
|
|
|
- //已收金额
|
|
|
- $fee1 = bcsub($one ,$red,2);
|
|
|
- //未收金额
|
|
|
- $fee2 = bcsub(bcsub(bcsub($value->contract_fee, $fee1,2), $bad, 2),$red,2);
|
|
|
- //红冲金额
|
|
|
- $fee3 = $red;
|
|
|
- //坏账金额
|
|
|
- $fee4 = $bad;
|
|
|
-
|
|
|
- $return[] = [
|
|
|
- 'order_number' => $value->order_number,
|
|
|
- 'model_type_title' => $model_type_title,
|
|
|
- 'sales_order_type_title' => $sales_order_type_title,
|
|
|
- 'sign_time' => $sign_time,
|
|
|
- 'plat_order' => $value->plat_order,
|
|
|
- 'plat_type_title' => $plat_type_title,
|
|
|
- 'product_total' => $value->product_total,
|
|
|
- 'other_fee' => $value->other_fee,
|
|
|
- 'discount_fee' => $value->discount_fee,
|
|
|
- 'contract_fee' => $value->contract_fee,
|
|
|
- 'fee' => $fee[$value->id] ?? "",
|
|
|
- 'dispatch_company' => $dispatch[$value->id] ?? '',
|
|
|
- 'fee1' => $fee1,
|
|
|
- 'fee2' => $fee2,
|
|
|
- 'fee3' => $fee3,
|
|
|
- 'fee4' => $fee4,
|
|
|
- 'crt_time' => $crt_time,
|
|
|
- 'crt_name' => $emp_map[$value->crt_id] ?? "",
|
|
|
- 'state_title' => $state,
|
|
|
- 'invoice_state_title' => SalesOrder::$invoice_state[$value->invoice_state] ?? '',
|
|
|
- 'invoice_arr' => $invoice_arr,
|
|
|
- 'pay_way' => $basic_map[$value->pay_way] ?? "",
|
|
|
- 'product_title' => $val['title'],
|
|
|
- 'product_code' => $val['code'],
|
|
|
- 'product_size' => $val['size'],
|
|
|
- 'product_rate' => $val['rate'],
|
|
|
- 'product_price' => $val['price'],
|
|
|
- 'product_num' => $val['number'],
|
|
|
- 'product_final_amount' => $val['final_amount'],
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- $header = ['合同单号','销售类型','产品类型','签订时间','平台单号','平台类型','产品合计','其他费用','优惠金额','合同金额','指派金额','派遣门店','已收金额','未收金额','红冲金额','坏账金额','创建时间','创建人','订单状态','发货状态','发货单号','付款方式','产品名称','产品编码','产品规格','产品税率','产品单价','产品数量','产品合同金额'];
|
|
|
-
|
|
|
- return $this->saveExportData($return,$header);
|
|
|
- }
|
|
|
-
|
|
|
- public function three($ergs){
|
|
|
- $id = $ergs['id'];
|
|
|
-
|
|
|
- // 导出数据
|
|
|
- $return = [];
|
|
|
-
|
|
|
- DB::table('payment_receipt')
|
|
|
- ->whereIn('id', $id)
|
|
|
- ->select('id','order_number','account','pay_way','type','data_type','payment_receipt_date','mark','crt_time','crt_id','state')
|
|
|
- ->orderBy('id','desc')
|
|
|
- ->chunk(500,function ($data) use(&$return){
|
|
|
- $data = $data->toArray();
|
|
|
- $emp_map = Employee::whereIn('id',array_unique(array_column($data,'crt_id')))
|
|
|
- ->pluck('emp_name','id')
|
|
|
- ->toArray();
|
|
|
- $array = array_unique(array_merge_recursive(array_column($data,'account'),array_column($data,'pay_way')));
|
|
|
- $basic_map = BasicType::whereIn('id',$array)
|
|
|
- ->pluck('title','id')
|
|
|
- ->toArray();
|
|
|
- $info = PaymentReceiptInfo::where('del_time',0)
|
|
|
- ->where('type',PaymentReceiptInfo::type_three)
|
|
|
- ->whereIn('payment_receipt_id',array_column($data,'id'))
|
|
|
- ->get()->toArray();
|
|
|
- $map = [];
|
|
|
- foreach ($info as $value){
|
|
|
- $map[$value['payment_receipt_id']][] = [
|
|
|
- 'payment_receipt_id' => $value['payment_receipt_id'],
|
|
|
- 'data_order_no' => $value['data_order_no'],
|
|
|
- 'amount' => $value['amount']
|
|
|
- ];
|
|
|
- }
|
|
|
-
|
|
|
- $flag = [];
|
|
|
- foreach ($data as $value){
|
|
|
- $account_title = $basic_map[$value->account] ?? '';
|
|
|
- $pay_way_title = $basic_map[$value->pay_way] ?? '';
|
|
|
- $crt_time = empty($value->crt_time) ? '' : date('Y-m-d',$value->crt_time);
|
|
|
- $payment_receipt_date= empty($value->payment_receipt_date) ? '' : date('Y-m-d',$value->payment_receipt_date);
|
|
|
- $state_title = PaymentReceipt::$name[$value->state] ?? '';
|
|
|
-
|
|
|
- $product_tmp = $map[$value->id] ?? [];
|
|
|
-
|
|
|
- foreach ($product_tmp as $val){
|
|
|
- if(in_array($val['payment_receipt_id'], $flag)){
|
|
|
- $return[] = [
|
|
|
- 'order_number' => "",
|
|
|
- 'account' => "",
|
|
|
- 'pay_way' => "",
|
|
|
- 'type' => "",
|
|
|
- 'data_type' => "",
|
|
|
- 'payment_receipt_date' => "",
|
|
|
- 'mark' => "",
|
|
|
- 'crt_time' => "",
|
|
|
- 'crt_name' => "",
|
|
|
- 'state_title' => "",
|
|
|
- 'data_order_no' => $val['data_order_no'],
|
|
|
- 'amount' => $val['amount'],
|
|
|
- ];
|
|
|
- }else{
|
|
|
- $flag[] = $val['payment_receipt_id'];
|
|
|
- $return[] = [
|
|
|
- 'order_number' => $value->order_number,
|
|
|
- 'account' => $account_title,
|
|
|
- 'pay_way' => $pay_way_title,
|
|
|
- 'type' => PaymentReceipt::$model_type[$value->type] ?? '',
|
|
|
- 'data_type' => PaymentReceipt::$data_type[$value->data_type] ?? '',
|
|
|
- 'payment_receipt_date' => $payment_receipt_date,
|
|
|
- 'mark' => $value->mark,
|
|
|
- 'crt_time' => $crt_time,
|
|
|
- 'crt_name' => $emp_map[$value->crt_id] ?? "",
|
|
|
- 'state_title' => $state_title,
|
|
|
- 'data_order_no' => $val['data_order_no'],
|
|
|
- 'amount' => $val['amount'],
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- $header = ['收付款单号','收付款账户','支付方式','收付款类型','关联单号类型','日期','备注','创建时间','创建人','订单状态','关联单号','金额'];
|
|
|
-
|
|
|
- return $this->saveExportData($return,$header);
|
|
|
- }
|
|
|
-
|
|
|
- public function four($ergs){
|
|
|
- $id = $ergs['id'];
|
|
|
-
|
|
|
- // 导出数据
|
|
|
- $return = [];
|
|
|
-
|
|
|
- DB::table('construction')
|
|
|
- ->whereIn('id', $id)
|
|
|
- ->select('id','order_number','title','sales_order_id','handover_time','install_method','install_position','mark','urgency','start_time','end_time','crt_time','crt_id','state',"construction_fee")
|
|
|
- ->orderBy('id','desc')
|
|
|
- ->chunk(500,function ($data) use(&$return){
|
|
|
- $data = $data->toArray();
|
|
|
- $emp_map = Employee::whereIn('id',array_unique(array_column($data,'crt_id')))
|
|
|
- ->pluck('emp_name','id')
|
|
|
- ->toArray();
|
|
|
- $construction_info = ConstructionInfo::where('del_time',0)
|
|
|
- ->where('type',ConstructionInfo::type_three)
|
|
|
- ->whereIn('construction_id',array_unique(array_column($data,'id')))
|
|
|
- ->select('construction_id','employee_id')
|
|
|
- ->get()->toArray();
|
|
|
- $emp_map2 = Employee::whereIn('id',array_unique(array_column($construction_info,'employee_id')))
|
|
|
- ->pluck('emp_name','id')
|
|
|
- ->toArray();
|
|
|
- $construction_info_map = [];
|
|
|
- foreach ($construction_info as $value){
|
|
|
- $emp = $emp_map2[$value['employee_id']] ?? "";
|
|
|
- if(! $emp) continue;
|
|
|
- if(isset($construction_info_map[$value['construction_id']])){
|
|
|
- $construction_info_map[$value['construction_id']] .= ',' . $emp;
|
|
|
- }else{
|
|
|
- $construction_info_map[$value['construction_id']] = $emp;
|
|
|
- }
|
|
|
- }
|
|
|
- $sales = SalesOrder::whereIn('id',array_unique(array_column($data,'sales_order_id')))->select('order_number','id','handover_time')->get()->toArray();
|
|
|
- $sales_map = [];
|
|
|
- foreach ($sales as $value){
|
|
|
- $sales_map[$value['id']] = $value;
|
|
|
- }
|
|
|
-
|
|
|
- $array = array_unique(array_merge_recursive(array_column($data,'install_method'),array_column($data,'urgency'),array_column($data,'install_position')));
|
|
|
- $basic_map = BasicType::whereIn('id',$array)
|
|
|
- ->pluck('title','id')
|
|
|
- ->toArray();
|
|
|
-
|
|
|
- $product = [];
|
|
|
- $p_info = ConstructionProductInfo::where('del_time',0)
|
|
|
- ->whereIn('construction_id',array_unique(array_column($data,'id')))
|
|
|
- ->get()->toArray();
|
|
|
- $map = (new ProductService())->getProductDetail(array_column($p_info,'product_id'));
|
|
|
- foreach ($p_info as $value){
|
|
|
- $tmp = $map[$value['product_id']] ?? [];
|
|
|
- $value['title'] = $tmp['title'] ?? "";
|
|
|
- $value['code'] = $tmp['code'] ?? "";
|
|
|
- $value['size'] = $tmp['size'] ?? "";
|
|
|
- $value['unit'] = $tmp['unit'] ?? "";
|
|
|
- $value['bar_code'] = $tmp['bar_code'] ?? "";
|
|
|
- $product[$value['construction_id']][] = $value;
|
|
|
- }
|
|
|
-
|
|
|
- $flag = [];
|
|
|
- foreach ($data as $value){
|
|
|
- $tmp_sales = $sales_map[$value->sales_order_id] ?? [];
|
|
|
- $handover_time = $value->handover_time ? date("Y-m-d") : "";
|
|
|
- $sales_order_number = $tmp_sales['order_number'];
|
|
|
- $crt_time = empty($value->crt_time) ? '' : date('Y-m-d',$value->crt_time);
|
|
|
- $install_position_title = $basic_map[$value->install_position] ?? '';
|
|
|
- $install_method_title = $basic_map[$value->install_position] ?? '';
|
|
|
- $urgency_title = $basic_map[$value->urgency] ?? '';
|
|
|
- $start_time = $value->start_time ? date("Y-m-d H:i",$value->start_time) : '';
|
|
|
- $end_time = $value->end_time ? date("Y-m-d H:i",$value->end_time) : '';
|
|
|
- $construction_period = $start_time . '——' . $end_time;
|
|
|
- $state = Construction::$name[$value->state] ?? '';
|
|
|
- $product_tmp = $product[$value->id] ?? [];
|
|
|
- $emp_tmp = $construction_info_map[$value->id] ?? "";
|
|
|
- foreach ($product_tmp as $val){
|
|
|
- if(in_array($val['construction_id'], $flag)){
|
|
|
- $return[] = [
|
|
|
- 'order_number' => "",
|
|
|
- 'title' => "",
|
|
|
- 'sales_order_title' => "",
|
|
|
- 'money' => "",
|
|
|
- 'emp' => '',
|
|
|
- 'handover_time' => "",
|
|
|
- 'install_method' => "",
|
|
|
- 'install_position' => "",
|
|
|
- 'mark' => "",
|
|
|
- 'urgency' => "",
|
|
|
- 'construction_period' => "",
|
|
|
- 'state_title' => "",
|
|
|
- 'crt_time' => "",
|
|
|
- 'crt_name' => "",
|
|
|
- 'product_title' => $val['title'],
|
|
|
- 'product_code' => $val['code'],
|
|
|
- 'product_size' => $val['size'],
|
|
|
- 'product_price' => $val['price'],
|
|
|
- 'product_num' => $val['number'],
|
|
|
- 'product_final_amount' => $val['final_amount'],
|
|
|
- ];
|
|
|
- }else{
|
|
|
- $flag[] = $val['construction_id'];
|
|
|
- $return[] = [
|
|
|
- 'order_number' => $value->order_number,
|
|
|
- 'title' => $value->title,
|
|
|
- 'sales_order_title' => $sales_order_number,
|
|
|
- 'money' => $value->construction_fee,
|
|
|
- 'emp' => $emp_tmp,
|
|
|
- 'handover_time' => $handover_time,
|
|
|
- 'install_method' => $install_method_title,
|
|
|
- 'install_position' => $install_position_title,
|
|
|
- 'mark' => $value->mark,
|
|
|
- 'urgency' => $urgency_title,
|
|
|
- 'construction_period' => $construction_period,
|
|
|
- 'state_title' => $state,
|
|
|
- 'crt_time' => $crt_time,
|
|
|
- 'crt_name' => $emp_map[$value->crt_id] ?? "",
|
|
|
- 'product_title' => $val['title'],
|
|
|
- 'product_code' => $val['code'],
|
|
|
- 'product_size' => $val['size'],
|
|
|
- 'product_price' => $val['price'],
|
|
|
- 'product_num' => $val['number'],
|
|
|
- 'product_final_amount' => $val['final_amount'],
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- $header = ['施工单号','工单来源','关联单号','施工费用','负责人','交车日期','安装方式','安装地点','备注','紧急程度','施工时间','订单状态','创建时间','创建人','产品名称','产品编码','产品规格','产品单价','产品数量','产品合同金额'];
|
|
|
-
|
|
|
- return $this->saveExportData($return,$header);
|
|
|
- }
|
|
|
-
|
|
|
- public function five($ergs){
|
|
|
- $id = $ergs['id'];
|
|
|
-
|
|
|
- // 导出数据
|
|
|
- $return = [];
|
|
|
-
|
|
|
- DB::table('purchase_order')
|
|
|
- ->whereIn('id', $id)
|
|
|
- ->select('order_number','id','depart_id','top_depart_id','mark','crt_time','state','crt_id','order_type','sales_order_id','supplier','purchase_id','purchase_total','discount_fee','other_fee','total','storehouse_id')
|
|
|
- ->orderBy('id','desc')
|
|
|
- ->chunk(500,function ($data) use(&$return){
|
|
|
- $data = $data->toArray();
|
|
|
- $array = array_unique(array_merge_recursive(array_column($data,'crt_id'),array_column($data,'purchase_id')));
|
|
|
- $emp_map = Employee::whereIn('id',$array)
|
|
|
- ->pluck('emp_name','id')
|
|
|
- ->toArray();
|
|
|
-
|
|
|
- $sales = SalesOrder::whereIn('id',array_unique(array_column($data,'sales_order_id')))->pluck('order_number','id')->toArray();
|
|
|
-
|
|
|
- $supplier = Supplier::whereIn('id',array_unique(array_column($data,'supplier')))
|
|
|
- ->pluck('title','id')
|
|
|
- ->toArray();
|
|
|
-
|
|
|
- $product = [];
|
|
|
- $p_info = PurchaseOrderInfo::where('del_time',0)->whereIn('purchase_order_id',array_unique(array_column($data,'id')))
|
|
|
- ->get()->toArray();
|
|
|
- $map = (new ProductService())->getProductDetail(array_column($p_info,'product_id'));
|
|
|
- foreach ($p_info as $value){
|
|
|
- $tmp = $map[$value['product_id']] ?? [];
|
|
|
- $value['title'] = $tmp['title'] ?? "";
|
|
|
- $value['code'] = $tmp['code'] ?? "";
|
|
|
- $value['size'] = $tmp['size'] ?? "";
|
|
|
- $value['unit'] = $tmp['unit'] ?? "";
|
|
|
- $value['bar_code'] = $tmp['bar_code'] ?? "";
|
|
|
- $product[$value['purchase_order_id']][] = $value;
|
|
|
- }
|
|
|
-
|
|
|
- //获取发货信息
|
|
|
-// $invoice_map = (new InvoiceOrderService())->getInvoiceData($data);
|
|
|
-
|
|
|
- $flag = [];
|
|
|
- foreach ($data as $value){
|
|
|
- $tmp_supplier = $supplier[$value->supplier] ?? "";
|
|
|
- $crt_name = $emp_map[$value->crt_id] ?? "";
|
|
|
- $purchase_name = $emp_map[$value->purchase_id] ?? "";
|
|
|
- $sales_order = $sales[$value->sales_order_id] ?? "";
|
|
|
- $crt_time = empty($value->crt_time) ? '' : date('Y-m-d',$value->crt_time);
|
|
|
- //发货信息
|
|
|
- $state_title = PurchaseOrder::$name[$value->state] ?? '';
|
|
|
-// $invoice_state = "未发货";
|
|
|
-// if(! empty($invoice_map[$value->order_number])) $invoice_state = implode(',',$invoice_map[$value->order_number]);
|
|
|
-// $state_message = "订单状态:" . $state_title . "\n"."是否发货:" . $invoice_state;
|
|
|
- $state_message = $state_title;
|
|
|
- $product_tmp = $product[$value->id] ?? [];
|
|
|
-
|
|
|
- foreach ($product_tmp as $val){
|
|
|
- if(in_array($val['purchase_order_id'], $flag)){
|
|
|
- $return[] = [
|
|
|
- 'order_number' => "",
|
|
|
- 'sales_order_number' => "",
|
|
|
- 'purchase_name' => "",
|
|
|
- 'product_total' => "",
|
|
|
- 'supplier' => "",
|
|
|
- 'purchase_amount' => "",
|
|
|
- 'other_fee' => "",
|
|
|
- 'discount_fee' => "",
|
|
|
- 'state_title' => "",
|
|
|
- 'crt_time' => "",
|
|
|
- 'crt_name' => "",
|
|
|
- 'product_title' => $val['title'],
|
|
|
- 'product_code' => $val['code'],
|
|
|
- 'product_size' => $val['size'],
|
|
|
- 'product_price' => $val['price'],
|
|
|
- 'product_num' => $val['number'],
|
|
|
- ];
|
|
|
- }else{
|
|
|
- $flag[] = $val['purchase_order_id'];
|
|
|
- $return[] = [
|
|
|
- 'order_number' => $value->order_number,
|
|
|
- 'sales_order_number' => $sales_order,
|
|
|
- 'purchase_name' => $purchase_name,
|
|
|
- 'product_total' => $value->total,
|
|
|
- 'supplier' => $tmp_supplier,
|
|
|
- 'purchase_amount' => $value->purchase_total,
|
|
|
- 'other_fee' => $value->other_fee,
|
|
|
- 'discount_fee' => $value->discount_fee,
|
|
|
- 'state_title' => $state_title,
|
|
|
- 'crt_time' => $crt_time,
|
|
|
- 'crt_name' => $crt_name,
|
|
|
- 'product_title' => $val['title'],
|
|
|
- 'product_code' => $val['code'],
|
|
|
- 'product_size' => $val['size'],
|
|
|
- 'product_price' => $val['price'],
|
|
|
- 'product_num' => $val['number'],
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ $list['data'] = $data;
|
|
|
});
|
|
|
|
|
|
- $header = ['采购单号','关联单号','采购人','产品合计','供应商','采购金额','其他费用','优惠金额','订单状态','创建时间','创建人','产品名称','产品编码','产品规格','产品单价','产品数量'];
|
|
|
+ $header = ['合同单号'];
|
|
|
|
|
|
return $this->saveExportData($return,$header);
|
|
|
}
|