|
@@ -546,16 +546,24 @@ class PaymentReceiptService extends Service
|
|
|
->where('type',PaymentReceiptInfo::type_three)
|
|
|
->where('data_order_type',PaymentReceipt::data_type_one)
|
|
|
->whereIn('data_order_no',$search)
|
|
|
- ->where('data_type',$data['type'])
|
|
|
- ->select('payment_receipt_id','data_order_no','amount')
|
|
|
+// ->where('data_type',$data['type'])
|
|
|
+ ->select('payment_receipt_id','data_order_no','amount','data_type')
|
|
|
->get()->toArray();
|
|
|
- $info_array = [];
|
|
|
+ $info_array = $red = [];
|
|
|
foreach ($info as $value){
|
|
|
if($payment_receipt_id > 0 && $value['payment_receipt_id'] == $payment_receipt_id) continue;
|
|
|
- if(isset($info_array[$value['data_order_no']])){
|
|
|
- $info_array[$value['data_order_no']] += $value['amount'];
|
|
|
- }else{
|
|
|
- $info_array[$value['data_order_no']] = $value['amount'];
|
|
|
+ if($value['data_type'] == PaymentReceipt::type_one){
|
|
|
+ if(isset($info_array[$value['data_order_no']])){
|
|
|
+ $info_array[$value['data_order_no']] += $value['amount'];
|
|
|
+ }else{
|
|
|
+ $info_array[$value['data_order_no']] = $value['amount'];
|
|
|
+ }
|
|
|
+ }elseif($value['data_type'] == PaymentReceipt::type_three){
|
|
|
+ if(isset($red[$value['data_order_no']])){
|
|
|
+ $red[$value['data_order_no']] += $value['amount'];
|
|
|
+ }else{
|
|
|
+ $red[$value['data_order_no']] = $value['amount'];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -570,11 +578,12 @@ class PaymentReceiptService extends Service
|
|
|
}
|
|
|
|
|
|
foreach ($result as $value){
|
|
|
- //收款 = 总金额 - 已收 - 退货退款
|
|
|
+ //收款 = 总金额 - (已收 - 红冲) - 退货退款
|
|
|
//$max = $value['total_amount'] - $tmp_receipt - $tmp_return;
|
|
|
$tmp_receipt = $info_array[$value['order_number']] ?? 0;
|
|
|
+ $tmp_red = $red[$value['order_number']] ?? 0;
|
|
|
$tmp_return = $return_exchange_array[$value['order_number']] ?? 0;
|
|
|
- $max = bcsub(bcsub($value['total_amount'], $tmp_receipt,2), $tmp_return, 2);
|
|
|
+ $max = bcsub(bcsub($value['total_amount'], bcsub($tmp_receipt,$tmp_red,2),2), $tmp_return, 2);
|
|
|
if($map[$value['order_number']] > $max) return [false, $value['order_number'] . '的金额填写上限是' . $max];
|
|
|
}
|
|
|
}elseif($data['type'] == PaymentReceipt::type_three){
|
|
@@ -602,7 +611,7 @@ class PaymentReceiptService extends Service
|
|
|
foreach ($result as $value){
|
|
|
//红冲 = 审核后的收款单金额 - 已红冲
|
|
|
$tmp_receipt = $info_one_array[$value['order_number']] ?? 0;
|
|
|
- $tmp_return = $info_array[$value['order_number']] ?? 0;
|
|
|
+ $tmp_return = $red[$value['order_number']] ?? 0;
|
|
|
$max = bcsub($tmp_receipt, $tmp_return, 2);
|
|
|
if($map[$value['order_number']] > $max) return [false, $value['order_number'] . '的金额填写上限是' . $max];
|
|
|
}
|
|
@@ -628,16 +637,24 @@ class PaymentReceiptService extends Service
|
|
|
->where('type',PaymentReceiptInfo::type_three)
|
|
|
->where('data_order_type',PaymentReceipt::data_type_two)
|
|
|
->whereIn('data_order_no',$search)
|
|
|
- ->where('data_type',$data['type'])
|
|
|
- ->select('payment_receipt_id','data_order_no','amount')
|
|
|
+// ->where('data_type',$data['type'])
|
|
|
+ ->select('payment_receipt_id','data_order_no','amount','data_type')
|
|
|
->get()->toArray();
|
|
|
- $info_array = [];
|
|
|
+ $info_array = $red = [];
|
|
|
foreach ($info as $value){
|
|
|
if($payment_receipt_id > 0 && $value['payment_receipt_id'] == $payment_receipt_id) continue;
|
|
|
- if(isset($info_array[$value['data_order_no']])){
|
|
|
- $info_array[$value['data_order_no']] += $value['amount'];
|
|
|
- }else{
|
|
|
- $info_array[$value['data_order_no']] = $value['amount'];
|
|
|
+ if($value['data_type'] == PaymentReceipt::type_one){
|
|
|
+ if(isset($info_array[$value['data_order_no']])){
|
|
|
+ $info_array[$value['data_order_no']] += $value['amount'];
|
|
|
+ }else{
|
|
|
+ $info_array[$value['data_order_no']] = $value['amount'];
|
|
|
+ }
|
|
|
+ }elseif($value['data_type'] == PaymentReceipt::type_three){
|
|
|
+ if(isset($red[$value['data_order_no']])){
|
|
|
+ $red[$value['data_order_no']] += $value['amount'];
|
|
|
+ }else{
|
|
|
+ $red[$value['data_order_no']] = $value['amount'];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -652,11 +669,12 @@ class PaymentReceiptService extends Service
|
|
|
}
|
|
|
|
|
|
foreach ($result as $value){
|
|
|
- //收款 = 总金额 - 已收 - 退货退款
|
|
|
+ //收款 = 总金额 - (已收 - 红冲) - 退货退款
|
|
|
//$max = $value['total_amount'] - $tmp_receipt - $tmp_return;
|
|
|
$tmp_receipt = $info_array[$value['order_number']] ?? 0;
|
|
|
+ $tmp_red = $red[$value['order_number']] ?? 0;
|
|
|
$tmp_return = $return_exchange_array[$value['order_number']] ?? 0;
|
|
|
- $max = bcsub(bcsub($value['total_amount'], $tmp_receipt,2), $tmp_return, 2);
|
|
|
+ $max = bcsub(bcsub($value['total_amount'], bcsub($tmp_receipt,$tmp_red,2),2), $tmp_return, 2);
|
|
|
if($map[$value['order_number']] > $max) return [false, $value['order_number'] . '的金额填写上限是' . $max];
|
|
|
}
|
|
|
}elseif($data['type'] == PaymentReceipt::type_three){
|
|
@@ -684,7 +702,7 @@ class PaymentReceiptService extends Service
|
|
|
foreach ($result as $value){
|
|
|
//红冲 = 审核后的收款单金额 - 已红冲
|
|
|
$tmp_receipt = $info_one_array[$value['order_number']] ?? 0;
|
|
|
- $tmp_return = $info_array[$value['order_number']] ?? 0;
|
|
|
+ $tmp_return = $red[$value['order_number']] ?? 0;
|
|
|
$max = bcsub($tmp_receipt, $tmp_return, 2);
|
|
|
if($map[$value['order_number']] > $max) return [false, $value['order_number'] . '的金额填写上限是' . $max];
|
|
|
}
|
|
@@ -709,16 +727,24 @@ class PaymentReceiptService extends Service
|
|
|
->where('type',PaymentReceiptInfo::type_three)
|
|
|
->where('data_order_type',PaymentReceipt::data_type_three)
|
|
|
->whereIn('data_order_no',$search)
|
|
|
- ->where('data_type',$data['type'])
|
|
|
- ->select('payment_receipt_id','data_order_no','amount')
|
|
|
+// ->where('data_type',$data['type'])
|
|
|
+ ->select('payment_receipt_id','data_order_no','amount','data_type')
|
|
|
->get()->toArray();
|
|
|
- $info_array = [];
|
|
|
+ $info_array = $red = [];
|
|
|
foreach ($info as $value){
|
|
|
if($payment_receipt_id > 0 && $value['payment_receipt_id'] == $payment_receipt_id) continue;
|
|
|
- if(isset($info_array[$value['data_order_no']])){
|
|
|
- $info_array[$value['data_order_no']] += $value['amount'];
|
|
|
- }else{
|
|
|
- $info_array[$value['data_order_no']] = $value['amount'];
|
|
|
+ if($value['data_type'] == PaymentReceipt::type_one){
|
|
|
+ if(isset($info_array[$value['data_order_no']])){
|
|
|
+ $info_array[$value['data_order_no']] += $value['amount'];
|
|
|
+ }else{
|
|
|
+ $info_array[$value['data_order_no']] = $value['amount'];
|
|
|
+ }
|
|
|
+ }elseif($value['data_type'] == PaymentReceipt::type_three){
|
|
|
+ if(isset($red[$value['data_order_no']])){
|
|
|
+ $red[$value['data_order_no']] += $value['amount'];
|
|
|
+ }else{
|
|
|
+ $red[$value['data_order_no']] = $value['amount'];
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -733,11 +759,12 @@ class PaymentReceiptService extends Service
|
|
|
}
|
|
|
|
|
|
foreach ($result as $value){
|
|
|
- //收款 = 总金额(订单金额 + 其他费用) - 已收 - 退换货
|
|
|
+ //收款 = 总金额(订单金额 + 其他费用) - (已收 - 红冲) - 退换货
|
|
|
$tmp_receipt = $info_array[$value['order_number']] ?? 0;
|
|
|
+ $tmp_red = $red[$value['order_number']] ?? 0;
|
|
|
$total = bcadd($value['total_amount'],$value['other_fee'],2);
|
|
|
$tmp_return = $return_exchange_array[$value['order_number']] ?? 0;
|
|
|
- $max = bcsub($total, $tmp_receipt, 2);
|
|
|
+ $max = bcsub($total, bcsub($tmp_receipt,$tmp_red,2), 2);
|
|
|
$max = bcsub($max, $tmp_return, 2);
|
|
|
if($map[$value['order_number']] > $max) return [false, $value['order_number'] . '的金额填写上限是' . $max];
|
|
|
}
|
|
@@ -766,7 +793,7 @@ class PaymentReceiptService extends Service
|
|
|
foreach ($result as $value){
|
|
|
//红冲 = 审核后的收款单金额 - 已红冲
|
|
|
$tmp_receipt = $info_one_array[$value['order_number']] ?? 0;
|
|
|
- $tmp_return = $info_array[$value['order_number']] ?? 0;
|
|
|
+ $tmp_return = $red[$value['order_number']] ?? 0;
|
|
|
$max = bcsub($tmp_receipt, $tmp_return, 2);
|
|
|
if($map[$value['order_number']] > $max) return [false, $value['order_number'] . '的金额填写上限是' . $max];
|
|
|
}
|