移除废弃代码&&增加管理端备货单查看

This commit is contained in:
mzl
2025-09-11 17:13:28 +08:00
parent fe64299303
commit 7e83949ed5
5 changed files with 1007 additions and 570 deletions
+7 -324
View File
@@ -11,7 +11,6 @@ use app\common\model\StockOrders;
use app\common\model\SysCurrency;
use support\Request;
use app\common\model\User;
use support\exception\BusinessException;
use support\Db;
use support\Model;
use app\admin\model\ApprovalInstances;
@@ -97,123 +96,6 @@ class StockOrdersService
return $config;
}
// public function serviceStore2(Request $request, array $data = [])
// {
// // 关联表较多,增加事务处理
// return Db::transaction(function () use ($request, $data) {
// $data = $this->preProcess('Store', $data, $request);
// $dl = $this->getDataLimitFromRequest($request);
// $created = $this->logicCreate($data, $dl); // 表1
// // 车辆
// $cifTotalAmount = 0;
// $cifTotalAmountRate = 0;
// $cifTotalAmountCurrency = 'CNY';
// // $profit = 0;
// foreach ($data['veh_list'] as $veh) {
// $veh['order_id'] = $created->id;
// // 唯一标识
// $uniqueIdStr = "";
// $uniqueIdStr .= $veh['sku_id'];
// $uniqueIdStr .= $veh['model_snapshot'];
// $uniqueIdStr .= $veh['color_interior_code'];
// $uniqueIdStr .= $veh['color_exterior_code'];
// $uniqueIdStr .= $veh['mileage'];
// $uniqueIdStr .= json($veh['modify_list']);
// $veh['unique_id'] = md5($uniqueIdStr);
// $item = StockOrderItems::create($veh); // 表2
// // 金额 // 表3
// // $item->addMoney('official_price', $veh['official_price']['currency'], $veh['official_price']['amount'], $veh['official_price']['rate'], '官方指导价');
// // $item->addMoney('discount_price', $veh['discount_price']['currency'], $veh['discount_price']['amount'], $veh['discount_price']['rate'], '优惠价');
// if ($veh['unit_price']['amount']) {
// $item->addMoney('unit_price', $veh['unit_price']['currency'], $veh['unit_price']['amount'], $veh['unit_price']['rate'], '单价');
// }
// if ($veh['total_price']['amount']) {
// $item->addMoney('total_price', $veh['total_price']['currency'], $veh['total_price']['amount'], $veh['total_price']['rate'], '总价');
// }
// if ($veh['handling_fee']['amount']) {
// $item->addMoney('handling_fee', $veh['handling_fee']['currency'], $veh['handling_fee']['amount'], $veh['handling_fee']['rate'], '手续费');
// }
// if ($veh['fob_transport_fee']['amount']) {
// $item->addMoney('fob_transport_fee', $veh['fob_transport_fee']['currency'], $veh['fob_transport_fee']['amount'], $veh['fob_transport_fee']['rate'], 'FOB运输费');
// }
// if ($veh['port_misc_fee']['amount']) {
// $item->addMoney('port_misc_fee', $veh['port_misc_fee']['currency'], $veh['port_misc_fee']['amount'], $veh['port_misc_fee']['rate'], '港杂');
// }
// if ($veh['retrofit_fee']['amount']) {
// $item->addMoney('retrofit_fee', $veh['retrofit_fee']['currency'], $veh['retrofit_fee']['amount'], $veh['retrofit_fee']['rate'], '改装费');
// }
// if ($veh['ocean_freight']['amount']) {
// $item->addMoney('ocean_freight', $veh['ocean_freight']['currency'], $veh['ocean_freight']['amount'], $veh['ocean_freight']['rate'], '海运费');
// }
// // 二手车 or 新车
// if ($veh['mileage'] > 0) {
// if ($veh['listing_price']['amount']) {
// $item->addMoney('listing_price', $veh['listing_price']['currency'], $veh['listing_price']['amount'], $veh['listing_price']['rate'], '二手挂牌价');
// }
// if ($veh['reduction_price']['amount']) {
// $item->addMoney('reduction_price', $veh['reduction_price']['currency'], $veh['reduction_price']['amount'], $veh['reduction_price']['rate'], '二手减价');
// }
// $ttPrice = ($veh['listing_price']['amount'] / $created->contract_exchange_rate);
// $ddPrice = $veh['reduction_price']['amount'];
// } else {
// if ($veh['official_price']['amount']) {
// $item->addMoney('official_price', $veh['official_price']['currency'], $veh['official_price']['amount'], $veh['official_price']['rate'], '官方指导价');
// }
// if ($veh['discount_price']['amount'] ) {
// $item->addMoney('discount_price', $veh['discount_price']['currency'], $veh['discount_price']['amount'], $veh['discount_price']['rate'], '优惠价');
// }
// $ttPrice = ($veh['official_price']['amount'] / $created->contract_exchange_rate);
// $ddPrice = $veh['discount_price']['amount'];
// }
// // 利润
// $profit = (float)$veh['unit_price']['amount']
// - (float)$ttPrice
// - (float)$ddPrice
// - (float)$veh['handling_fee']['amount']
// - (float)$veh['fob_transport_fee']['amount']
// - (float)$veh['port_misc_fee']['amount']
// - (float)$veh['retrofit_fee']['amount']
// - (float)$veh['ocean_freight']['amount'];
// $item->addMoney('profit', $veh['unit_price']['currency'], $profit, $veh['unit_price']['rate'], '利润');
// // cif_total_amount
// $cifTotalAmount += $veh['total_price']['amount'];
// $cifTotalAmountRate = $veh['retrofit_fee']['rate'];
// $cifTotalAmountCurrency = $veh['retrofit_fee']['currency'];
// // 改装
// if (count($veh['modify_list']) > 0) {
// foreach ($veh['modify_list'] as $modify) {
// $modify['order_item_id'] = $item->id;
// StockOrderItemOptions::create($modify); // 表4
// }
// }
// }
// // 计算&&插入 表1
// $created->addMoney('cif_total_amount', $cifTotalAmountCurrency, $cifTotalAmount, $cifTotalAmountRate, '合计到岸价');
// // 账户
// if (count($data['account_list']) > 0) {
// foreach ($data['account_list'] as $account) {
// $account['order_id'] = $created->id;
// $account['remit_date'] = strtotime($account['remit_date']);
// StockOrderAccounts::create($account); // 表5
// }
// }
// return $this->postProcess('Store', $created);
// });
// }
public function beforeServiceStore($data, Request $request)
{
$userId = $request->user->uid;
@@ -318,138 +200,6 @@ class StockOrdersService
return $res;
}
// public function pdfData2($item)
// {
// $vehList = [];
// $mv = [];
// $mfy = '';
// $index = 0;
// foreach ($item->items as $k => $v) {
// // 存在则数量加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, '.', ',');
// continue;
// }
// $index += 1;
// // 处理金额
// foreach ($v->moneyValues as $money) {
// $mv[$money->field] = [
// 'currency' => $money->currency,
// 'amount' => $money->amount,
// 'rate' => $money->exchange_rate,
// 'currency_symbol' => SysCurrency::where('currency_code', $money->currency)->value('currency_symbol'),
// ];
// }
// // 处理改装
// foreach ($v->options as $my) {
// $mfy .= $my->option_name_snapshot.' ';
// }
// // 处理结果集
// $vehList[$v->unique_id] = [
// '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,
// 'unit_price' => $mv['unit_price']['amount'],
// 'total_price' => $mv['total_price']['amount'],
// 'unit_price_symbol' => $mv['unit_price']['currency_symbol'],
// 'total_price_symbol' => $mv['total_price']['currency_symbol'],
// 'unit_price_text' => $mv['unit_price']['currency_symbol'].number_format($mv['unit_price']['amount'], 2, '.', ','),
// 'total_price_text' => $mv['total_price']['currency_symbol'].number_format($mv['total_price']['amount'], 2, '.', ',')
// ];
// // 根据里程处理 新车or二手车
// if ($v->mileage > 0) {
// if (isset($mv['reduction_price'])) {
// $vehList[$v->unique_id]['reduction_price'] = $mv['reduction_price']['amount'];
// $vehList[$v->unique_id]['reduction_price_symbol'] = $mv['reduction_price']['currency_symbol'];
// $vehList[$v->unique_id]['reduction_price_text'] = $mv['reduction_price']['currency_symbol'].number_format($mv['reduction_price']['amount'], 2, '.', ',');
// }
// $vehList[$v->unique_id]['listing_price'] = $mv['listing_price']['amount'];
// $vehList[$v->unique_id]['listing_price_symbol'] = $mv['listing_price']['currency_symbol'];
// $vehList[$v->unique_id]['listing_price_text'] = $mv['listing_price']['currency_symbol'].number_format($mv['listing_price']['amount'], 2, '.', ',');
// } else {
// if (isset($mv['discount_price'])) {
// $vehList[$v->unique_id]['discount_price'] = $mv['discount_price']['amount'];
// $vehList[$v->unique_id]['discount_price_symbol'] = $mv['discount_price']['currency_symbol'];
// $vehList[$v->unique_id]['discount_price_text'] = $mv['discount_price']['currency_symbol'].number_format($mv['discount_price']['amount'], 2, '.', ',');
// }
// $vehList[$v->unique_id]['official_price'] = $mv['official_price']['amount'];
// $vehList[$v->unique_id]['official_price_symbol'] = $mv['official_price']['currency_symbol'];
// $vehList[$v->unique_id]['official_price_text'] = $mv['official_price']['currency_symbol'].number_format($mv['official_price']['amount'], 2, '.', ',');
// }
// }
// $accList = [];
// $accIndex = 1;
// 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,
// ];
// $accIndex += 1;
// }
// $cifTotalAmount = 0.00;
// if ($item->moneyValues) {
// $cifTotalAmountSysboml = SysCurrency::where('currency_code', $item->moneyValues->currency)->value('currency_symbol');
// $cifTotalAmount = $cifTotalAmountSysboml.sprintf("%.2f", $item->moneyValues->amount, $item->moneyValues->exchange_rate);
// }
// $profit = 0.00;
// $profit = $this->calculateProfit($mv, $item);
// $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' => $vehList,
// 'contract_exchange_rate' => $item->contract_exchange_rate,
// 'cif_total_amount' => $item->cif_total_amount,
// '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),
// // 账户
// 'account_list' => $accList,
// 'acc_index' => $accIndex,
// 'cif_total_amount' => $cifTotalAmount,
// 'profit' => $profit
// ];
// return $veh;
// }
public function pdfData($item)
{
$vehList = [];
@@ -486,14 +236,6 @@ class StockOrdersService
$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) {
@@ -501,8 +243,7 @@ class StockOrdersService
'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, '.', ','),
// 'currency_info' => 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, '.', ',')
];
}
@@ -524,59 +265,9 @@ class StockOrdersService
'color_exterior_snapshot' => $v->color_exterior_snapshot,
'num' => 1,
'modify' => $mfy,
'mileage' => $v->mileage,
// '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',
'mileage' => $v->mileage
];
// 根据里程处理 新车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 (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, '.', ',');
// }
// }
$vehList[$v->unique_id] = $vehListItem + $mv;
}
@@ -587,7 +278,6 @@ class StockOrdersService
'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'),
];
}
@@ -641,14 +331,11 @@ class StockOrdersService
// 账户
'account_list' => $accList,
'acc_index' => count($accList)+1,
// 'cif_total_amount' => $cifTotalAmount,
// 'cif_total_amount_symbol' => $cifTotalAmountSymbol,
// 'profit' => number_format($totalProfit, 2, '.', ''),
'currency_symbol' => $item->settlement_currency,
'sign_imgs' => $this->queryAppro($item->id),
'contract_url' => (!empty($item->contract)) ? (new \app\common\service\OssService)->generatePrivateUrl($item->contract) : ''
];
// var_dump($veh);
return $veh;
}
@@ -665,16 +352,12 @@ class StockOrdersService
return [];
}
$signImg = User::whereIn('id', $records)->pluck('sign_img')->toArray();
if (count($signImg) == 0) {
return [];
}
$signImgs = [];
foreach ($signImg as $k => $v) {
$signImgs[$k] = (!empty($v))?(new \app\common\service\OssService)->generatePrivateUrl($v):'';
foreach ($records as $k => $v) {
$signImg = User::where('id', $v)->value('sign_img');
$signImgs[$k] = (!empty($signImg))?(new \app\common\service\OssService)->generatePrivateUrl($signImg):'';
}
return $signImgs;
}