This commit is contained in:
mzl
2025-09-11 15:31:37 +08:00
parent ee75d29831
commit eb13146763
5 changed files with 475 additions and 82 deletions
+2 -2
View File
@@ -50,7 +50,7 @@ class StockOrders extends Model
'trade_term_id', 'trade_term_snapshot', 'clearance_port_id', 'clearance_port_snapshot',
'latest_arrival_date', 'contract_exchange_rate', 'settlement_currency', 'status',
'remark', 'created_at', 'updated_at', 'deleted_at',
'object_id', 'contract', 'is_use', 'is_final', 'approval_status', 'file_url', 'pick_up_date', 'collect_all_date'
'object_id', 'contract', 'is_use', 'is_final', 'approval_status', 'file_url', 'pick_up_date', 'collect_all_date', 'profit_total'
];
/**
@@ -87,7 +87,7 @@ class StockOrders extends Model
*/
public function moneyValues()
{
return $this->hasOne(VehMoneyValue::class, 'object_id', 'id')->where('object_scene', 'stock_orders');
return $this->hasMany(VehMoneyValue::class, 'object_id', 'id')->where('object_scene', 'stock_orders');
}
@@ -0,0 +1,319 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>合塑实业-汽车事业部-备货单(客户下定)</title>
<style>
/* 横版:A4 297mm,左右各 12mm => 可用宽度 273mm */
@page { margin: 12mm; }
body {
font-family: 'notosanssc', 'DejaVu Sans', Arial, sans-serif;
font-size: 10pt;
line-height: 1.3;
color: #000;
background: #fff;
}
.container {
width: 273mm; /* 横向版心 */
margin: 0 auto;
background: #fff;
}
.header {
text-align: center;
margin-bottom: 10pt;
padding-bottom: 6pt;
}
.title {
font-size: 14pt;
font-weight: bold;
margin-bottom: 6pt;
}
.sub-title {
font-size: 9pt;
color: #000;
margin: 0 6pt;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 10pt;
font-size: 9pt;
table-layout: fixed; /* 横向固定布局,配合 colgroup 更稳 */
}
th, td {
border: 0.5pt solid #000;
padding: 6pt 6pt;
text-align: center;
vertical-align: middle;
word-break: break-all;
}
th {
background-color: #f0f0f0;
font-weight: bold;
color: #000;
}
/* 跨页友好 */
thead { display: table-header-group; }
tfoot { display: table-row-group; }
tr, img { page-break-inside: avoid; }
/* 信息类表格左对齐 */
.info-table td,
.logistics-table td { text-align: left; }
.info-label { font-weight: bold; color: #000; }
.info-value { color: #000; }
.summary-row {
background-color: #f0f0f0;
font-weight: bold;
}
.payment-title {
background-color: #f0f0f0;
font-weight: bold;
text-align: center;
vertical-align: middle;
white-space: nowrap;
}
.nowrap { white-space: nowrap; }
</style>
</head>
<body>
<div class="container">
<!-- 头部 -->
<div class="header">
<h1 class="title">合塑实业-汽车事业部-备货单(客户下定)</h1>
<div>
<span class="sub-title">备货单号: <?php echo htmlspecialchars($data['order_no'] ?? 'N/A'); ?></span>
<span class="sub-title">业务员: <?php echo htmlspecialchars($data['salesperson_snapshot'] ?? ' - '); ?></span>
</div>
</div>
<!-- 基本信息 -->
<table class="info-table">
<colgroup>
<col style="width:18%">
<col style="width:15%">
<col style="width:14%">
<col style="width:14%">
<col style="width:19%">
<col style="width:20%">
</colgroup>
<tbody>
<tr>
<td><span class="info-label">阿里订单号/PI号:</span> <span class="info-value"><?php echo htmlspecialchars($data['pi_no'] ?? ' - '); ?></span></td>
<td><span class="info-label">日期:</span> <span class="info-value nowrap"><?php echo htmlspecialchars($data['biz_date'] ?? ' - '); ?></span></td>
<td><span class="info-label">关目的国:</span> <span class="info-value"><?php echo htmlspecialchars($data['clearance_country_snapshot'] ?? ' - '); ?></span></td>
<td><span class="info-label">客户来源:</span> <span class="info-value"><?php echo htmlspecialchars($data['customer_source_snapshot'] ?? ' - '); ?></span></td>
<td><span class="info-label">客户名称:</span> <span class="info-value"><?php echo htmlspecialchars($data['customer_snapshot'] ?? ' - '); ?></span></td>
<td><span class="info-label">客户所在国:</span> <span class="info-value"><?php echo htmlspecialchars($data['customer_country_snapshot'] ?? ' - '); ?></span></td>
</tr>
</tbody>
</table>
<!-- 产品列表 -->
<table class="product-table">
<colgroup>
<col style="width:6%">
<col style="width:34%">
<col style="width:6%">
<col style="width:6%">
<col style="width:6%">
<col style="width:14%">
<col style="width:8%">
<col style="width:8%">
<col style="width:6%">
<col style="width:6%">
</colgroup>
<thead>
<tr>
<th>编号</th>
<th>车型</th>
<th>数量/台</th>
<th>颜色/外</th>
<th>内饰</th>
<th>改装</th>
<th class="nowrap">官方指导价/二手挂牌价</th>
<th class="nowrap">优惠</th>
<th class="nowrap">单价</th>
<th class="nowrap">总价</th>
<th class="nowrap">利润</th>
</tr>
</thead>
<tbody>
<?php foreach (($data['veh_list'] ?? []) as $vehicle): ?>
<tr>
<td><?php echo htmlspecialchars($vehicle['index'] ?? ' - '); ?></td>
<td>
<?php echo htmlspecialchars($vehicle['model_snapshot'] ?? ' - '); ?>
<?php if ($vehicle['mileage'] > 0): ?>
<span class="nowrap">(<?php echo htmlspecialchars($vehicle['mileage']).'km'; ?>)</span>
<?php endif; ?>
</td>
<td><?php echo htmlspecialchars($vehicle['num'] ?? ' - '); ?></td>
<td><?php echo htmlspecialchars($vehicle['color_exterior_snapshot'] ?? ' - '); ?></td>
<td><?php echo htmlspecialchars($vehicle['color_interior_snapshot'] ?? ' - '); ?></td>
<td><?php echo htmlspecialchars($vehicle['modify'] ?? ' - '); ?></td>
<?php if ($vehicle['mileage'] > 0): ?>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['listing_price_text'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['reduction_price_text'] ?? ' - '); ?></td>
<?php else: ?>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['official_price_text'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['discount_price_text'] ?? ' - '); ?></td>
<?php endif; ?>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['unit_price_text'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['total_price_text'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['profit_text'] ?? ' - '); ?></td>
</tr>
<?php endforeach; ?>
<tr class="summary-row">
<td colspan="6" style="text-align:left;">
<span class="info-label">合同汇率:</span> <span class="info-value"><?php echo htmlspecialchars($data['contract_exchange_rate'] ?? ' - '); ?></span>
</td>
<td colspan="5" style="text-align:left;">
<span class="info-label">合计到岸价:</span> <span class="info-value"><?php echo htmlspecialchars($data['cif_total_amount'] ?? ' - '); ?></span>
</td>
</tr>
</tbody>
</table>
<!-- 物流信息 -->
<table class="logistics-table">
<colgroup>
<col style="width:16%">
<col style="width:18%">
<col style="width:12%">
<col style="width:18%">
<col style="width:22%">
<col style="width:14%">
</colgroup>
<tbody>
<tr>
<td><span class="info-label">清关人:</span> <span class="info-value"><?php echo htmlspecialchars($data['declarant_name'] ?? ' - '); ?></span></td>
<?php if ($data['is_final'] == 1): ?>
<td><span class="info-label">全款收齐日:</span> <span class="info-value nowrap"><?php echo htmlspecialchars($data['collect_all_date'] ?? ' - '); ?></span></td>
<?php else: ?>
<td><span class="info-label">预计发运日期:</span> <span class="info-value nowrap"><?php echo htmlspecialchars($data['eta_ship_date'] ?? ' - '); ?></span></td>
<?php endif; ?>
<td><span class="info-label">出运方式:</span> <span class="info-value"><?php echo htmlspecialchars($data['shipping_method_snapshot'] ?? ' - '); ?></span></td>
<td><span class="info-label">国内收货港:</span> <span class="info-value"><?php echo htmlspecialchars($data['domestic_port_snapshot'] ?? ' - '); ?></span></td>
<td><span class="info-label">贸易条款/清关目的港:</span> <span class="info-value"><?php echo htmlspecialchars($data['trade_term_snapshot'] ?? ' - '); ?>/<?php echo htmlspecialchars($data['clearance_port_snapshot'] ?? ' - '); ?></span></td>
<?php if ($data['is_final'] == 1): ?>
<td><span class="info-label">提车日期:</span> <span class="info-value nowrap"><?php echo htmlspecialchars($data['pick_up_date'] ?? ' - '); ?></span></td>
<?php else: ?>
<td><span class="info-label">最迟到港时间:</span> <span class="info-value nowrap"><?php echo htmlspecialchars($data['latest_arrival_date'] ?? ' - '); ?></span></td>
<?php endif; ?>
</tr>
</tbody>
</table>
<!-- 计划收款信息 -->
<table class="payment-table">
<colgroup>
<col style="width:12%">
<col style="width:10%">
<col style="width:14%">
<col style="width:12%">
<col style="width:12%">
<col style="width:20%">
<col style="width:10%">
</colgroup>
<thead>
<tr>
<th style="width:24mm" rowspan="<?php echo htmlspecialchars($data['acc_index']); ?>">计划收款信息</th>
<th>序号</th>
<th>汇款国</th>
<th>日期</th>
<th>币种</th>
<th>账户</th>
<th>汇款人</th>
<th>金额</th>
</tr>
</thead>
<tbody>
<?php foreach (($data['account_list'] ?? []) as $account): ?>
<tr>
<td class="nowrap"><?php echo htmlspecialchars($account['index'] ?? ' - '); ?></td>
<td><?php echo htmlspecialchars($account['remit_country_name_snapshot'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($account['remit_date'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($account['currency_name_snapshot'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($account['account_name_snapshot'] ?? ' - '); ?></td>
<td style="text-align:left;"><?php echo htmlspecialchars($account['remitter_name'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($account['amount'] ?? ' - '); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<!-- PDF 底部签名区 -->
<div style="margin-top: 6mm; font-size: 12px;">
<!-- 左侧:业务员签字 / 备发货负责人签字 -->
<div style="width: 50%; float: left; text-align: left;">
<!-- 行距通过 margin-bottom 控制;行内元素通过固定行高和 vertical-align: middle 垂直居中 -->
<div style="height: 14mm; line-height: 14mm; margin-bottom: 5mm;">
<span>业务员签字:</span>
<?php if (!empty($data['sign_img_url'])): ?>
<img src="<?php echo htmlspecialchars($data['sign_img_url']); ?>" style="height: 12mm; vertical-align: middle;">
<?php else: ?>
<span style="display:inline-block; width:21mm; height:12mm; vertical-align: middle; border-bottom:0.2mm solid #000;"></span>
<?php endif; ?>
</div>
<div style="height: 14mm; line-height: 14mm;">
<span>备发货负责人签字:</span>
<?php if (!empty($data['sign_img_url'])): ?>
<img src="<?php echo htmlspecialchars($data['sign_img_url']); ?>" style="height: 12mm; vertical-align: middle;">
<?php else: ?>
<span style="display:inline-block; width:21mm; height:12mm; vertical-align: middle; border-bottom:0.2mm solid #000;"></span>
<?php endif; ?>
</div>
</div>
<!-- 右侧:组长签字 / 日期 -->
<div style="width: 50%; float: right; text-align: left;">
<div style="height: 14mm; line-height: 14mm; margin-bottom: 5mm;">
<span>组长签字:</span>
<?php if (!empty($data['sign_img_url'])): ?>
<img src="<?php echo htmlspecialchars($data['sign_img_url']); ?>" style="height: 12mm; vertical-align: middle;">
<?php else: ?>
<span style="display:inline-block; width:21mm; height:12mm; vertical-align: middle; border-bottom:0.2mm solid #000;"></span>
<?php endif; ?>
</div>
<div style="height: 14mm; line-height: 14mm;">
<span>日期:</span>
<?php
$_dt = $data['signed_date'] ?? ($data['created_at'] ?? '');
if (is_numeric($_dt)) {
echo htmlspecialchars(date('Y-m-d', (int)$_dt));
} elseif (!empty($_dt)) {
$t = strtotime($_dt);
echo $t ? htmlspecialchars(date('Y-m-d', $t)) : ' - ';
} else {
echo ' - ';
}
?>
</div>
</div>
<div style="clear: both;"></div>
</div>
</div>
</body>
</html>
@@ -163,16 +163,16 @@
<td><?php echo htmlspecialchars($vehicle['modify'] ?? ' - '); ?></td>
<?php if ($vehicle['mileage'] > 0): ?>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['listing_price'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['reduction_price'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['listing_price']['currency_info'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['reduction_price']['currency_info'] ?? ' - '); ?></td>
<?php else: ?>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['official_price'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['discount_price'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['official_price']['currency_info'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['discount_price']['currency_info'] ?? ' - '); ?></td>
<?php endif; ?>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['unit_price_text'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['total_price_text'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['profit_text'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['unit_price']['currency_info'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['total_price']['currency_info'] ?? ' - '); ?></td>
<td class="nowrap"><?php echo htmlspecialchars($vehicle['profit']['currency_info'] ?? ' - '); ?></td>
</tr>
<?php endforeach; ?>
@@ -181,7 +181,7 @@
<span class="info-label">合同汇率:</span> <span class="info-value"><?php echo htmlspecialchars($data['contract_exchange_rate'] ?? ' - '); ?></span>
</td>
<td colspan="5" style="text-align:left;">
<span class="info-label">合计到岸价:</span> <span class="info-value"><?php echo htmlspecialchars($data['cif_total_amount'] ?? ' - '); ?></span>
<span class="info-label">合计到岸价:</span> <span class="info-value"><?php echo htmlspecialchars($data['cif_total_amount']['currency_info'] ?? ' - '); ?></span>
</td>
</tr>
</tbody>
+21 -6
View File
@@ -66,12 +66,14 @@ class StockOrdersController extends BaseController
}
if (count($data['moneyValues']) > 0) {
$data['cif_total_amount'] = [
'exchange_rate' => $data['moneyValues']['exchange_rate'],
'amount' => $data['moneyValues']['amount'],
'currency' => $data['moneyValues']['currency'],
'id' => $data['moneyValues']['id']
];
foreach ($data['moneyValues'] as $mvs) {
$data[$mvs['field']] = [
'exchange_rate' => $mvs['exchange_rate'],
'amount' => $mvs['amount'],
'currency' => $mvs['currency'],
'id' => $mvs['id']
];
}
}
foreach ($data['items'] as &$item) {
@@ -144,6 +146,19 @@ class StockOrdersController extends BaseController
return $this->error($e->getMessage());
}
}
public function detail(Request $request)
{
try {
$raw = $this->service->serviceDetail($request);
$data = $this->transformData($raw, method_exists($this, 'printFormat')
? [$this, 'printFormat']
: null);
return $this->success($data);
} catch (\Throwable $e) {
return $this->error($e->getMessage());
}
}
/**
* 启动审批
+125 -66
View File
@@ -71,6 +71,7 @@ class StockOrdersService
case 'approval':
$config['where']['id'] = $p['id'];
break;
case 'detail':
case 'show':
$config['where']['id'] = $p['id'];
@@ -223,10 +224,10 @@ class StockOrdersService
$data['salesperson_snapshot'] = User::where('id', $userId)->value('name') ?? '';
$data['approval_status'] = $data['approval_status'] == 1 ? 1 : 0;
if ($data['is_final'] == 1) {
// if ($data['is_final'] == 1) {
$data['pick_up_date'] = strtotime($data['pick_up_date']);
$data['collect_all_date'] = strtotime($data['collect_all_date']);
}
// }
return $data;
}
@@ -452,18 +453,45 @@ class StockOrdersService
$vehList = [];
$index = 0;
$totalProfit = 0; // 总利润
// $priceFields = [
// 'official_price', // '官方指导价',
// 'discount_price', // '优惠',
// 'listing_price', // '二手挂牌价价',
// 'reduction_price', // '优惠',
// 'handling_fee', // '手续费',
// 'retrofit_fee', // '改装费',
// 'fob_transport_fee', // 'FOB运输费',
// 'port_misc_fee', // '港杂',
// 'ocean_freight', // '海运费',
// 'unit_price', // '单价',
// 'total_price', // '总价',
// // 'profit', // '利润'
// ];
foreach ($item->items as $k => $v) {
$currencyInfo = SysCurrency::where('currency_code', $item->settlement_currency)->first(['currency_symbol', 'currency_name'])->toArray();
// 存在则数量加1
if (count($vehList) > 0 && isset($vehList[$v->unique_id])) {
$vehList[$v->unique_id]['num'] += 1;
$vehList[$v->unique_id]['total_price'] += $vehList[$v->unique_id]['unit_price'];
$vehList[$v->unique_id]['total_price_text'] = $vehList[$v->unique_id]['total_price_symbol'].number_format($vehList[$v->unique_id]['total_price'], 2, '.', ',');
$vehList[$v->unique_id]['total_price']['currency_info'] = $currencyInfo['currency_symbol'].number_format($vehList[$v->unique_id]['total_price']['amount']*$vehList[$v->unique_id]['num'], 2, '.', ',');
$vehList[$v->unique_id]['profit']['currency_info'] = $currencyInfo['currency_symbol'].number_format($vehList[$v->unique_id]['profit']['amount']*$vehList[$v->unique_id]['num'], 2, '.', ',');
continue;
}
$index += 1;
// 合计到岸价
// $cifTotalAmount = 0.00;
// $cifTotalAmountSymbol = '';
// if ($item->moneyValues) {
// $cifTotalInfo = SysCurrency::where('currency_code', $item->moneyValues->currency)->select('currency_symbol', 'currency_name')->get()->toArray();
// $cifTotalAmount = $currencyInfo['currency_symbol'].sprintf("%.2f", $item->moneyValues->amount);
// }
// 处理金额 (每次循环重新初始化)
$mv = [];
foreach ($v->moneyValues as $money) {
@@ -471,7 +499,8 @@ class StockOrdersService
'currency' => $money->currency,
'amount' => $money->amount,
'rate' => $money->exchange_rate,
'currency_symbol' => SysCurrency::where('currency_code', $money->currency)->value('currency_symbol'),
'currency_info' => SysCurrency::where('currency_code', $money->currency)->value('currency_symbol').number_format($money->amount, 2, '.', ','),
// 'currency_info' => SysCurrency::where('currency_code', $money->currency)->value('currency_symbol'),
];
}
@@ -494,52 +523,72 @@ class StockOrdersService
'num' => 1,
'modify' => $mfy,
'mileage' => $v->mileage,
'unit_price' => $mv['unit_price']['amount'] ?? 0,
'total_price' => $mv['total_price']['amount'] ?? 0,
'profit' => $itemProfit, // 单项利润
'profit_symbol' => $mv['unit_price']['currency_symbol'] ?? '',
'profit_text' => isset($mv['unit_price']['currency_symbol']) ?
$mv['unit_price']['currency_symbol'].number_format($itemProfit, 2, '.', ',') : '0.00',
'unit_price_symbol' => $mv['unit_price']['currency_symbol'] ?? '',
'total_price_symbol' => $mv['total_price']['currency_symbol'] ?? '',
'unit_price_text' => isset($mv['unit_price']['currency_symbol']) ?
$mv['unit_price']['currency_symbol'].number_format($mv['unit_price']['amount'], 2, '.', ',') : '0.00',
'total_price_text' => isset($mv['total_price']['currency_symbol']) ?
$mv['total_price']['currency_symbol'].number_format($mv['total_price']['amount'], 2, '.', ',') : '0.00'
// 'unit_price' => $mv['unit_price']['amount'] ?? 0,
// 'unit_price_symbol' => $mv['unit_price']['currency_symbol'] ?? '',
// 'unit_price_text' => isset($mv['unit_price']['currency_symbol']) ?
// $mv['unit_price']['currency_symbol'].number_format($mv['unit_price']['amount'], 2, '.', ',') : '0.00',
// 'total_price' => $mv['total_price']['amount'] ?? 0,
// 'total_price_symbol' => $mv['total_price']['currency_symbol'] ?? '',
// 'total_price_text' => isset($mv['total_price']['currency_symbol']) ?
// $mv['total_price']['currency_symbol'].number_format($mv['total_price']['amount'], 2, '.', ',') : '0.00',
// 'handling_fee' => $mv['handling_fee']['amount'] ?? 0,
// 'handling_fee_symbol' => $mv['handling_fee']['currency_symbol'] ?? '',
// 单项利润
// 'profit' => $itemProfit,
// 'profit_symbol' => $cifTotalInfo['currency_symbol'],
// 'profit_text' => isset($mv['unit_price']['currency_symbol']) ? $cifTotalInfo['currency_symbol'].number_format($itemProfit, 2, '.', ',') : '0.00',
];
// 根据里程处理 新车or二手车
if ($v->mileage > 0) {
// 二手车
if (isset($mv['reduction_price'])) {
$vehListItem['reduction_price'] = $mv['reduction_price']['amount'];
$vehListItem['reduction_price_symbol'] = $mv['reduction_price']['currency_symbol'];
$vehListItem['reduction_price_text'] = $mv['reduction_price']['currency_symbol'].number_format($mv['reduction_price']['amount'], 2, '.', ',');
}
// if ($v->mileage > 0) {
// // 二手车
// if (isset($mv['reduction_price'])) {
// $vehListItem['reduction_price'] = $mv['reduction_price']['amount'];
// $vehListItem['reduction_price_symbol'] = $mv['reduction_price']['currency_symbol'];
// $vehListItem['reduction_price_text'] = $mv['reduction_price']['currency_symbol'].number_format($mv['reduction_price']['amount'], 2, '.', ',');
// }
if (isset($mv['listing_price'])) {
$vehListItem['listing_price'] = $mv['listing_price']['amount'];
$vehListItem['listing_price_symbol'] = $mv['listing_price']['currency_symbol'];
$vehListItem['listing_price_text'] = $mv['listing_price']['currency_symbol'].number_format($mv['listing_price']['amount'], 2, '.', ',');
}
} else {
// 新车
if (isset($mv['discount_price'])) {
$vehListItem['discount_price'] = $mv['discount_price']['amount'];
$vehListItem['discount_price_symbol'] = $mv['discount_price']['currency_symbol'];
$vehListItem['discount_price_text'] = $mv['discount_price']['currency_symbol'].number_format($mv['discount_price']['amount'], 2, '.', ',');
}
// if (isset($mv['listing_price'])) {
// $vehListItem['listing_price'] = $mv['listing_price']['amount'];
// $vehListItem['listing_price_symbol'] = $mv['listing_price']['currency_symbol'];
// $vehListItem['listing_price_text'] = $mv['listing_price']['currency_symbol'].number_format($mv['listing_price']['amount'], 2, '.', ',');
// }
// } else {
// // 新车
// if (isset($mv['discount_price'])) {
// $vehListItem['discount_price'] = $mv['discount_price']['amount'];
// $vehListItem['discount_price_symbol'] = $mv['discount_price']['currency_symbol'];
// $vehListItem['discount_price_text'] = $mv['discount_price']['currency_symbol'].number_format($mv['discount_price']['amount'], 2, '.', ',');
// }
if (isset($mv['official_price'])) {
$vehListItem['official_price'] = $mv['official_price']['amount'];
$vehListItem['official_price_symbol'] = $mv['official_price']['currency_symbol'];
$vehListItem['official_price_text'] = $mv['official_price']['currency_symbol'].number_format($mv['official_price']['amount'], 2, '.', ',');
}
}
// if (isset($mv['official_price'])) {
// $vehListItem['official_price'] = $mv['official_price']['amount'];
// $vehListItem['official_price_symbol'] = $mv['official_price']['currency_symbol'];
// $vehListItem['official_price_text'] = $mv['official_price']['currency_symbol'].number_format($mv['official_price']['amount'], 2, '.', ',');
// }
// }
$vehList[$v->unique_id] = $vehListItem;
$vehList[$v->unique_id] = $vehListItem + $mv;
}
// var_dump($item->moneyValues);
$mvs = [];
foreach ($item->moneyValues as $moneys) {
$mvs[$moneys->field] = [
'currency' => $moneys->currency,
'amount' => $moneys->amount,
'rate' => $moneys->exchange_rate,
'currency_info' => SysCurrency::where('currency_code', $moneys->currency)->value('currency_symbol').number_format($moneys->amount, 2, '.', ','),
// 'currency_info' => SysCurrency::where('currency_code', $money->currency)->value('currency_symbol'),
];
}
// var_dump($mvs);
$accList = [];
foreach ($item->accounts as $k => $v) {
$accList[] = [
@@ -553,12 +602,7 @@ class StockOrdersService
];
}
$cifTotalAmount = 0.00;
$cifTotalAmountSymbol = '';
if ($item->moneyValues) {
$cifTotalAmountSymbol = SysCurrency::where('currency_code', $item->moneyValues->currency)->value('currency_symbol');
$cifTotalAmount = $cifTotalAmountSymbol.sprintf("%.2f", $item->moneyValues->amount);
}
$veh = [
'order_no' => $item->order_no,
@@ -578,7 +622,8 @@ class StockOrdersService
'veh_list' => array_values($vehList), // 重新索引数组
'contract_exchange_rate' => $item->contract_exchange_rate,
'cif_total_amount' => $item->cif_total_amount,
'cif_total_amount' => $mvs['cif_total_amount'],
'profit_total' => $mvs['profit_total'],
'declarant_name' => $item->declarant_name,
'eta_ship_date' => date('Y-m-d', $item->eta_ship_date),
@@ -594,11 +639,12 @@ class StockOrdersService
// 账户
'account_list' => $accList,
'acc_index' => count($accList)+1,
'cif_total_amount' => $cifTotalAmount,
'cif_total_amount_symbol' => $cifTotalAmountSymbol,
'profit' => number_format($totalProfit, 2, '.', ''),
'profit_symbol' => $cifTotalAmountSymbol // 假设利润使用相同货币
// 'cif_total_amount' => $cifTotalAmount,
// 'cif_total_amount_symbol' => $cifTotalAmountSymbol,
// 'profit' => number_format($totalProfit, 2, '.', ''),
'currency_symbol' => $item->settlement_currency // 假设利润使用相同货币
];
// var_dump($veh);
return $veh;
}
@@ -613,6 +659,14 @@ class StockOrdersService
return $this->postProcess('Print', $item);
}
public function serviceDetail(Request $request)
{
$config = $this->buildQueryConfig($request, 'detail');
$item = $this->logicShow($config);
$pdfData = $this->pdfData($item);
return $this->postProcess('Detail', $pdfData);
}
/**
* 审批
*/
@@ -783,10 +837,11 @@ class StockOrdersService
*/
private function processVehicleItems($order, array $vehList): void
{
$cifTotalAmount = 0;
$cifTotalAmountRate = 0;
$cifTotalAmountCurrency = 'CNY';
$cifTotalAmount = 0.00;
// $cifTotalAmountRate = 0;
// $cifTotalAmountCurrency = 'CNY';
$profitTotalAmount = 0.00;
foreach ($vehList as $veh) {
$veh['order_id'] = $order->id;
$veh['unique_id'] = $this->generateVehicleUniqueId($veh);
@@ -798,23 +853,27 @@ class StockOrdersService
// 计算利润
$profit = $this->calculateProfit($veh, $order);
$item->addMoney('profit', $veh['unit_price']['currency'], $profit, $veh['unit_price']['rate'], '利润');
$item->addMoney('profit', $order->settlement_currency, $profit, $order->contract_exchange_rate, '利润');
// 累计到岸价
$cifTotalAmount += $veh['total_price']['amount'] ?? 0;
if (isset($veh['retrofit_fee']['rate'])) {
$cifTotalAmountRate = $veh['retrofit_fee']['rate'];
}
if (isset($veh['retrofit_fee']['currency'])) {
$cifTotalAmountCurrency = $veh['retrofit_fee']['currency'];
}
$profitTotalAmount += $profit;
// if (isset($veh['retrofit_fee']['rate'])) {
// $cifTotalAmountRate = $veh['retrofit_fee']['rate'];
// }
// if (isset($veh['retrofit_fee']['currency'])) {
// $cifTotalAmountCurrency = $veh['retrofit_fee']['currency'];
// }
// 处理改装项
$this->processModificationItems($item->id, $veh['modify_list'] ?? []);
}
// 保存合计到岸价
$order->addMoney('cif_total_amount', $cifTotalAmountCurrency, $cifTotalAmount, $cifTotalAmountRate, '合计到岸价');
$order->addMoney('cif_total_amount', $order->settlement_currency, $cifTotalAmount, $order->contract_exchange_rate, '合计到岸价');
// 利润
$order->addMoney('profit_total', $order->settlement_currency, $profitTotalAmount, $order->contract_exchange_rate, '总利润');
}
/**