|
@@ -184,4 +184,48 @@ class OrderController extends Controller
|
|
|
ProductSKU::query()->where('order_id', $order->id)->delete();
|
|
ProductSKU::query()->where('order_id', $order->id)->delete();
|
|
|
return redirect()->route('order.index');
|
|
return redirect()->route('order.index');
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public function revertMaf(Request $request, Order $order)
|
|
|
|
|
+ {
|
|
|
|
|
+ $ids = $request->validate([
|
|
|
|
|
+ 'ids' => 'required|json',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $ids = json_decode($ids['ids'], true);
|
|
|
|
|
+ $updated = [];
|
|
|
|
|
+ foreach ($ids as $mafId) {
|
|
|
|
|
+ $maf = ProductSKU::query()
|
|
|
|
|
+ ->where('order_id', $order->id)
|
|
|
|
|
+ ->where('id', $mafId)
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ if($maf) {
|
|
|
|
|
+ MafOrder::query()->where('id', $maf->maf_order_id)->increment('in_stock');
|
|
|
|
|
+ $maf->update(['maf_order_id' => null, 'status' => 'требуется']);
|
|
|
|
|
+ $updated[] = $maf;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return response()->json($updated);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function moveMaf(Request $request)
|
|
|
|
|
+ {
|
|
|
|
|
+ $data = $request->validate([
|
|
|
|
|
+ 'new_order_id' => 'required',
|
|
|
|
|
+ 'ids' => 'required|json',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $ids = json_decode($data['ids'], true);
|
|
|
|
|
+ $updated = [];
|
|
|
|
|
+ foreach ($ids as $mafId) {
|
|
|
|
|
+ $maf = ProductSKU::query()
|
|
|
|
|
+ ->where('id', $mafId)
|
|
|
|
|
+ ->first();
|
|
|
|
|
+ if($maf) {
|
|
|
|
|
+ $maf->update(['order_id' => $data['new_order_id']]);
|
|
|
|
|
+ // todo update comment: add previous address
|
|
|
|
|
+ $updated[] = $maf;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return response()->json($updated);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|