|
|
@@ -15,8 +15,8 @@ class OrderRejectingStatusService
|
|
|
//计算退回件问题
|
|
|
public function rejectedBillSyncRejectingStatus(RejectedBill $rejectedBill)
|
|
|
{
|
|
|
- $query = OrderIssueRejectedBill::query()->select('order_id')->where('logistic_number_return',$rejectedBill->logistic_number_return);
|
|
|
- $order = Order::query()->whereIn('id',$query)->first();
|
|
|
+ $query = OrderIssueRejectedBill::query()->select('order_id')->where('logistic_number_return', $rejectedBill->logistic_number_return);
|
|
|
+ $order = Order::query()->whereIn('id', $query)->first();
|
|
|
$this->syncRejectingStatus($order);
|
|
|
}
|
|
|
|
|
|
@@ -27,11 +27,18 @@ class OrderRejectingStatusService
|
|
|
{
|
|
|
if (!$order) return;
|
|
|
$rejecting_status = $this->getOrderRejectingStatus($order);
|
|
|
-
|
|
|
- OrderDetail::query()->updateOrCreate(
|
|
|
- ['order_id' => $order->id,],
|
|
|
- ['rejecting_status' => $rejecting_status,'is_new_rejecting' => $rejecting_status === '无' ? '无' : '有']
|
|
|
- );
|
|
|
+ $order_detail = OrderDetail::query()->where('order_id', $order->id)->first();
|
|
|
+ if (!$order_detail) {
|
|
|
+ OrderDetail::query()->create(
|
|
|
+ ['order_id' => $order->id, 'is_new_rejecting' => '有', 'rejecting_status' => $rejecting_status === '无' ? '无' : '有']
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (in_array($order_detail->is_new_rejecting, ['有', '已处理']) && $rejecting_status != '无') {
|
|
|
+ $order_detail->update(['rejecting_status' => $rejecting_status]);
|
|
|
+ } else {
|
|
|
+ $order_detail->update(['rejecting_status' => $rejecting_status, $rejecting_status => $rejecting_status === '无' ? '无' : '有']);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public function getOrderRejectingStatus(Order $order): string
|
|
|
@@ -52,7 +59,7 @@ class OrderRejectingStatusService
|
|
|
{
|
|
|
$rejected_bill_items = $this->getRejectedBillItems($order);
|
|
|
$map = [];
|
|
|
- if(count($rejected_bill_items) == 0) return $map;
|
|
|
+ if (count($rejected_bill_items) == 0) return $map;
|
|
|
foreach ($rejected_bill_items as $item) {
|
|
|
$code = $item->barcode_goods;
|
|
|
$amount = $item->amount;
|