|
|
|
@ -77,16 +77,22 @@ class OrdersController extends CommonController
|
|
|
|
|
|
|
|
|
|
|
|
public function changeItem(Request $request)
|
|
|
|
public function changeItem(Request $request)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$order_item = OrderItems::with("order")->find($request->item_id);
|
|
|
|
$order_item = OrderItems::with(["order", "siblings"])->find($request->item_id);
|
|
|
|
|
|
|
|
if (request()->is_batch) {
|
|
|
|
|
|
|
|
$order_items = $order_item->siblings;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$order_items = collect($order_item);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
foreach($order_items as $order_item) {
|
|
|
|
if ($order_item->paid_at && $request->total != $order_item->total) {
|
|
|
|
if ($order_item->paid_at && $request->total != $order_item->total) {
|
|
|
|
return $this->error("子订单已扣款,不支持后台更改价格,请通过其他方法进行更改");
|
|
|
|
return $this->error("子订单已扣款,不支持后台更改价格,请通过其他方法进行更改");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($order_item->total == 0 && $request->total != $order_item->total) {
|
|
|
|
if ($order_item->total == 0 && $request->total != $order_item->total) {
|
|
|
|
return $this->error("未服务子订单不支持后台更改价格,请通过其他方法进行更改");
|
|
|
|
return $this->error("未服务子订单不支持后台更改价格,请通过其他方法进行更改");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
$order_item->update([
|
|
|
|
$order_item->update([
|
|
|
|
"total" => $request->total
|
|
|
|
"total" => $request->total
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
@ -104,6 +110,7 @@ class OrdersController extends CommonController
|
|
|
|
"factors" => json_encode($factors)
|
|
|
|
"factors" => json_encode($factors)
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
DB::commit();
|
|
|
|
DB::commit();
|
|
|
|
return $this->success("处理成功!");
|
|
|
|
return $this->success("处理成功!");
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
} catch (\Exception $exception) {
|
|
|
|
|