From 35609b9d43519217c7e52474a29278e06425ee2e Mon Sep 17 00:00:00 2001 From: mzl Date: Mon, 13 Oct 2025 18:54:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=87=E8=B4=A7=E5=8D=95?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/StockOrdersService.php | 157 +--------------------- 1 file changed, 6 insertions(+), 151 deletions(-) diff --git a/app/common/service/StockOrdersService.php b/app/common/service/StockOrdersService.php index fdfd1fb..dd37378 100644 --- a/app/common/service/StockOrdersService.php +++ b/app/common/service/StockOrdersService.php @@ -219,146 +219,10 @@ class StockOrdersService return $res; } - public function pdfData2($item) - { - $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']['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; - - // 处理金额 (每次循环重新初始化) - $mv = []; - foreach ($v->moneyValues as $money) { - $mv[$money->field] = [ - 'currency' => $money->currency, - 'amount' => $money->amount, - 'rate' => $money->exchange_rate, - 'currency_info' => SysCurrency::where('currency_code', $money->currency)->value('currency_symbol').number_format($money->amount, 2, '.', ',') - ]; - } - - // 处理改装 (每次循环重新初始化) - $mfy = ''; - foreach ($v->options as $my) { - $mfy .= $my->option_name_snapshot.' '; - } - - // 计算单项利润并累加到总利润 - $itemProfit = $this->calculateProfit($mv, $item); - $totalProfit += $itemProfit; - - // 处理结果集 - $vehListItem = [ - 'index' => $index, - 'model_snapshot' => $v->model_snapshot, - 'color_interior_snapshot' => $v->color_interior_snapshot, - 'color_exterior_snapshot' => $v->color_exterior_snapshot, - 'num' => 1, - 'modify' => $mfy, - 'mileage' => $v->mileage - ]; - - $vehList[$v->unique_id] = $vehListItem + $mv; - } - - $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, '.', ','), - ]; - } - - $accList = []; - foreach ($item->accounts as $k => $v) { - $accList[] = [ - 'index' => '收款'.($k + 1), - 'remit_country_name_snapshot' => $v->remit_country_name_snapshot, - 'remit_date' => date('Y-m-d', $v->remit_date), - 'currency_name_snapshot' => $v->currency_name_snapshot, - 'account_name_snapshot' => $v->account_name_snapshot, - 'remitter_name' => $v->remitter_name, - 'amount' => $v->amount, - ]; - } - - - - $veh = [ - 'order_no' => $item->order_no, - 'salesperson_snapshot' => $item->salesperson_snapshot, - 'sign_img_url' => (!empty($item->salesperson->sign_img)) ? - (new \app\common\service\OssService)->generatePrivateUrl($item->salesperson->sign_img) : '', - 'created_at' => date('Y-m-d', strtotime($item->created_at)), - - 'pi_no' => $item->pi_no, - 'biz_date' => date('Y-m-d', $item->biz_date), - 'clearance_country_snapshot' => $item->clearance_country_snapshot, - 'customer_source_snapshot' => $item->customer_source_snapshot, - 'customer_snapshot' => $item->customer_snapshot, - 'customer_country_snapshot' => $item->customer_country_snapshot, - - // 订单项 - 'veh_list' => array_values($vehList), // 重新索引数组 - - 'contract_exchange_rate' => $item->contract_exchange_rate, - '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), - 'shipping_method_snapshot' => $item->shipping_method_snapshot, - 'domestic_port_snapshot' => $item->domestic_port_snapshot, - 'trade_term_snapshot' => $item->trade_term_snapshot, - 'clearance_port_snapshot' => $item->clearance_port_snapshot, - 'latest_arrival_date' => date('Y-m-d', $item->latest_arrival_date), - 'pick_up_date' => date('Y-m-d', $item->pick_up_date), - 'collect_all_date' => date('Y-m-d', $item->collect_all_date), - 'is_final' => $item->is_final, - - // 账户 - 'account_list' => $accList, - 'acc_index' => count($accList)+1, - 'currency_symbol' => $item->settlement_currency, - 'sign_imgs' => $this->queryAppro($item->id), - 'contract_url' => (!empty($item->contract)) ? (new \app\common\service\OssService)->generatePrivateUrl($item->contract) : '' - ]; - - return $veh; - } - + /** + * 查询审批 + */ public function queryAppro($bizId) { $instances = ApprovalInstances::where('biz_id', $bizId)->where('biz_type', 'stock_orders')->first(); @@ -610,9 +474,6 @@ class StockOrdersService private function processVehicleItems($order, array $vehList): void { $cifTotalAmount = 0.00; - // $cifTotalAmountRate = 0; - // $cifTotalAmountCurrency = 'CNY'; - $profitTotalAmount = 0.00; foreach ($vehList as $veh) { $veh['order_id'] = $order->id; @@ -631,13 +492,6 @@ class StockOrdersService $cifTotalAmount += $veh['total_price']['amount'] ?? 0; $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'] ?? []); } @@ -680,7 +534,8 @@ class StockOrdersService 'ocean_freight' => '海运费', 'commission' => '佣金', 'purchase_tax' => '购置税', - 'tax_refund' => '预估退税' + 'tax_refund' => '预估退税', + 'clearance_price' => '报关价', ]; foreach ($priceFields as $field => $description) { @@ -768,7 +623,7 @@ class StockOrdersService $taxRefund = (float)($veh['tax_refund']['amount'] ?? 0); // 退税额 是增加利润 - return $unitPrice - $ttPrice - $ddPrice - $handlingFee - $fobTransportFee - $portMiscFee - $retrofitFee - $oceanFreight - $commission - $purchaseTax + $taxRefund; + return $unitPrice - $ttPrice + $ddPrice - $handlingFee - $fobTransportFee - $portMiscFee - $retrofitFee - $oceanFreight - $commission - $purchaseTax + $taxRefund; } /**