|
@@ -322,4 +322,49 @@ class PaymentReceiptService extends Service
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
|
+
|
|
|
+ public function getPaymentReceiptDataList($data){
|
|
|
+ if(empty($data['data_order_no'])) return [false,'关联单号不能为空!'];
|
|
|
+
|
|
|
+ $order = PaymentReceipt::where('del_time',0)
|
|
|
+ ->where('data_order_no',$data['data_order_no'])
|
|
|
+ ->get()->toArray();
|
|
|
+
|
|
|
+ $emp_id = PaymentReceiptInfo::where('del_time',0)
|
|
|
+ ->whereIn('payment_receipt_id',array_column($order,'id'))
|
|
|
+ ->where('type',PaymentReceiptInfo::type_two)
|
|
|
+ ->get()->toArray();
|
|
|
+ $info = [];
|
|
|
+ if(! empty($emp_id)){
|
|
|
+ $emp_map = Employee::whereIn('id',array_unique(array_column($emp_id,'data_id')))
|
|
|
+ ->pluck('emp_name','id')
|
|
|
+ ->toArray();
|
|
|
+ foreach ($emp_id as $value){
|
|
|
+ $name = $emp_map[$value['data_id']] ?? "";
|
|
|
+ if(! isset($info[$value['data_id']])){
|
|
|
+ $info[$value['data_id']] .= $name . ',';
|
|
|
+ }else{
|
|
|
+ $info[$value['data_id']] = $name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $finished = $not_finished = 0;
|
|
|
+ foreach ($order as $key => $value){
|
|
|
+ $order[$key]['state_title'] = PaymentReceipt::$name[$value['state']] ?? '';
|
|
|
+ $order[$key]['payment_receipt_date'] = $value['payment_receipt_date'] ? date('Y-m-d',$value['payment_receipt_date']) : '';
|
|
|
+ if($value['state'] == PaymentReceipt::STATE_TWO){
|
|
|
+ $finished += $value['amount'];
|
|
|
+ }else{
|
|
|
+ $not_finished += $value['amount'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $return['receipt_amount'] = $finished;
|
|
|
+ $return['not_receipt_amount'] = $not_finished;
|
|
|
+ $return['all_count'] = count($order);
|
|
|
+ $return['list'] = $order;
|
|
|
+
|
|
|
+ return [true, $return];
|
|
|
+ }
|
|
|
}
|