fixed product title
This commit is contained in:
@@ -249,6 +249,7 @@ class SingleOrderController extends Controller
|
||||
}
|
||||
$data['order'] = $order = Order::create($data);
|
||||
$abshode = $this->resolveAbshodeProductContext($data);
|
||||
$productId = (int) ($data['product_id'] ?? $abshode['id'] ?? 0);
|
||||
$buyTransaction = [
|
||||
"cash" => $data['payment_amount'],
|
||||
"gold" => $data['amount'],
|
||||
@@ -256,13 +257,11 @@ class SingleOrderController extends Controller
|
||||
'active' => true,
|
||||
'order_id' => $order->id,
|
||||
'start_at' => now(),
|
||||
'title' => $abshode['title'] !== ''
|
||||
? self::productBuyTitle($abshode['title'])
|
||||
: self::meltedGoldBuyTitle(),
|
||||
'title' => $this->meltedOrProductBuyTitle($data),
|
||||
];
|
||||
if ($abshode['id'] > 0) {
|
||||
$buyTransaction['product_id'] = $abshode['id'];
|
||||
$buyTransaction['note'] = 'product_id:' . $abshode['id'];
|
||||
if ($productId > 0) {
|
||||
$buyTransaction['product_id'] = $productId;
|
||||
$buyTransaction['note'] = 'product_id:' . $productId;
|
||||
}
|
||||
new TransactionInterface($wallet_interface, $buyTransaction, 1, true, false);
|
||||
$response['1'] = 2;
|
||||
@@ -316,7 +315,7 @@ class SingleOrderController extends Controller
|
||||
'active' => true,
|
||||
'order_id' => $order->id,
|
||||
'start_at' => now(),
|
||||
'title' => self::productBuyTitle($data['product']['title'] ?? ''),
|
||||
'title' => $this->meltedOrProductBuyTitle($data),
|
||||
], 1, true, false);
|
||||
|
||||
|
||||
@@ -408,7 +407,7 @@ class SingleOrderController extends Controller
|
||||
'active' => true,
|
||||
'order_id' => $order->id,
|
||||
'start_at' => now(),
|
||||
'title' => self::productBuyTitle($data['product']['title'] ?? ''),
|
||||
'title' => $this->meltedOrProductBuyTitle($data),
|
||||
], 1, true, false);
|
||||
|
||||
}
|
||||
@@ -429,19 +428,18 @@ class SingleOrderController extends Controller
|
||||
}
|
||||
$data['order'] = $order = Order::create($data);
|
||||
$abshode = $this->resolveAbshodeProductContext($data);
|
||||
$productId = (int) ($data['product_id'] ?? $abshode['id'] ?? 0);
|
||||
$sellTransaction = [
|
||||
"gold" => $data['amount'],
|
||||
"cash" => $data['total_price'],
|
||||
'expire_at' => now(),
|
||||
'active' => true,
|
||||
'order_id' => $order->id,
|
||||
'title' => $abshode['title'] !== ''
|
||||
? self::productSellTitle($abshode['title'])
|
||||
: self::meltedGoldSellTitle(),
|
||||
'title' => $this->meltedOrProductSellTitle($data),
|
||||
];
|
||||
if ($abshode['id'] > 0) {
|
||||
$sellTransaction['product_id'] = $abshode['id'];
|
||||
$sellTransaction['note'] = 'product_id:' . $abshode['id'];
|
||||
if ($productId > 0) {
|
||||
$sellTransaction['product_id'] = $productId;
|
||||
$sellTransaction['note'] = 'product_id:' . $productId;
|
||||
}
|
||||
new TransactionInterface($wallet_interface, $sellTransaction, 2, false, true);
|
||||
|
||||
@@ -479,7 +477,7 @@ class SingleOrderController extends Controller
|
||||
'active' => true,
|
||||
'order_id' => $order->id,
|
||||
'start_at' => now(),
|
||||
'title' => self::productSellTitle($data['product']['title'] ?? ''),
|
||||
'title' => $this->meltedOrProductSellTitle($data),
|
||||
], 1, false, false);
|
||||
$data['transaction'][] = new TransactionInterface($wallet_interface, $_inp = [
|
||||
"number" => $data['number'],
|
||||
@@ -520,7 +518,7 @@ class SingleOrderController extends Controller
|
||||
'expire_at' => now(),
|
||||
'active' => true,
|
||||
'order_id' => $order->id,
|
||||
'title' => self::mainMetalBuyTitle(),
|
||||
'title' => $this->meltedOrProductSellTitle($data),
|
||||
], 12, true, false);
|
||||
$this->normalizeProductWalletGold($wallet_interface_product);
|
||||
new TransactionInterface($wallet_interface_product, [
|
||||
@@ -530,7 +528,7 @@ class SingleOrderController extends Controller
|
||||
'active' => true,
|
||||
'order_id' => $order->id,
|
||||
'start_at' => now(),
|
||||
'title' => self::productSellTitle($data['product']['title'] ?? ''),
|
||||
'title' => $this->meltedOrProductSellTitle($data),
|
||||
], 1, false, false);
|
||||
}
|
||||
|
||||
@@ -890,17 +888,20 @@ class SingleOrderController extends Controller
|
||||
private function productTitleFromData(array $data): ?string
|
||||
{
|
||||
$product = $data['product'] ?? null;
|
||||
if (!$product) {
|
||||
return null;
|
||||
}
|
||||
$title = null;
|
||||
|
||||
if (is_array($product)) {
|
||||
$title = $product['title'] ?? null;
|
||||
} else {
|
||||
$title = $product->title ?? null;
|
||||
if ($product) {
|
||||
if (is_array($product)) {
|
||||
$title = $product['title'] ?? null;
|
||||
} else {
|
||||
$title = $product->title ?? null;
|
||||
}
|
||||
}
|
||||
|
||||
$title = trim((string) $title);
|
||||
if ($title === '' && !empty($data['product_id'])) {
|
||||
$title = trim((string) Product::query()->whereKey((int) $data['product_id'])->value('title'));
|
||||
}
|
||||
|
||||
return $title !== '' ? $title : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user