From b47d23cd678c01b7591cdb295feded7d7410e38a Mon Sep 17 00:00:00 2001 From: mzl Date: Fri, 24 Oct 2025 11:15:09 +0800 Subject: [PATCH 1/3] Merge branch 'develop' --- app/common/logic/PurchaseOrdersLogic.php | 3 +- app/common/service/StockOrdersService.php | 57 ++++------------------- 2 files changed, 10 insertions(+), 50 deletions(-) diff --git a/app/common/logic/PurchaseOrdersLogic.php b/app/common/logic/PurchaseOrdersLogic.php index 500379d..0914f43 100644 --- a/app/common/logic/PurchaseOrdersLogic.php +++ b/app/common/logic/PurchaseOrdersLogic.php @@ -24,7 +24,7 @@ class PurchaseOrdersLogic public function getPiList() { return (new StockOrders())->where('pi_no', '!=', '') - ->select('pi_no') + ->select('pi_no', 'salesperson_snapshot') ->distinct() ->get(); } @@ -35,6 +35,7 @@ class PurchaseOrdersLogic public function getOrderNoListByPiNo($piNo) { return (new StockOrders())->where('pi_no', $piNo) + ->where('approval_status', 2) ->select('order_no', 'biz_date', 'salesperson_snapshot', 'id as stock_orders_id', 'salesperson_id') ->get(); } diff --git a/app/common/service/StockOrdersService.php b/app/common/service/StockOrdersService.php index f243654..76d2ab5 100644 --- a/app/common/service/StockOrdersService.php +++ b/app/common/service/StockOrdersService.php @@ -330,33 +330,25 @@ class StockOrdersService $data = $this->preProcess('Store', $data, $request); $dl = $this->getDataLimitFromRequest($request); $created = $this->logicCreate($data, $dl); - // 添加金额 $created->addMoney('cif_total', $data['cif_total']['currency'], $data['cif_total']['amount'], $data['cif_total']['rate'], '合计到岸价'); - // 处理车辆和账户信息 $this->processOrderItems($created, $data); - // 处理文件附件 $this->processOrderFiles($created, $data); - return $this->postProcess('Store', $created); }); } protected function onlyFillableData(Model|string $model, array $data, array $extraWhitelist = []): array { - // 兼容传类名或实例 $m = \is_string($model) ? new $model : $model; - // 1) 优先使用 fillable $keys = $m->getFillable(); - // 2) 若没配置 fillable(常见:用 guarded),回退到完整表字段,避免误伤 if (empty($keys)) { $keys = $m->getConnection() ->getSchemaBuilder() ->getColumnListing($m->getTable()); } - // 3) 允许额外白名单(如虚拟字段、JSON映射字段) if ($extraWhitelist) { $keys = array_merge($keys, $extraWhitelist); } @@ -413,11 +405,13 @@ class StockOrdersService // 过滤掉非库字段 $dbData = $this->onlyFillableData($config['model'], $data); // 更新主表 - $updated = $this->logicUpdateBy($config, $dbData); + $this->logicUpdateBy($config, $dbData); // 获取更新后的数据 $order = $this->logicShow($config); // 处理车辆和账户信息 $this->processOrderItems($order, $data, true); + // 添加金额 + $order->addMoney('cif_total', $data['cif_total']['currency'], $data['cif_total']['amount'], $data['cif_total']['rate'], '合计到岸价'); // 处理文件附件 $this->processOrderFiles($order, $data, true); return $this->postProcess('Update', $order); @@ -436,10 +430,8 @@ class StockOrdersService if ($isUpdate) { $this->clearExistingOrderItems($order->id); } - // 处理车辆项 $this->processVehicleItems($order, $data['veh_list'] ?? []); - // 处理账户项 $this->processAccountItems($order, $data['account_list'] ?? []); } @@ -552,7 +544,6 @@ class StockOrdersService $this->processVehiclePrices($item, $veh); // 累计到岸价 - // $cifTotalAmount += $veh['total_price']['amount'] ?? 0; $profitCurrency === '' ? $profitCurrency = $veh['profit']['currency'] ?? '' : ''; $profitRate === 0 ? $profitRate = $veh['profit']['rate'] ?? 0 : ''; $profitTotalAmount += $veh['profit']['amount'] ?? 0; @@ -572,7 +563,6 @@ class StockOrdersService $keysToRemove = ['vin', 'remark', 'modify_list', 'order_id']; $array = array_diff_key($veh, array_flip($keysToRemove)); $uniqueIdStr = json_encode($array); - return md5($uniqueIdStr); } @@ -600,6 +590,7 @@ class StockOrdersService // retention_price 留款/挂账 // car_price 车价 // accessory_price 配件费 + // increase_price 加价 // 基础费用 $priceFields = [ @@ -617,7 +608,8 @@ class StockOrdersService 'profit' => '利润', 'retention_price' => '挂账', 'car_price' => '车价', - 'accessory_price' => '配件费' + 'accessory_price' => '配件费', + 'increase_price' => '加价' ]; foreach ($priceFields as $field => $description) { @@ -771,12 +763,10 @@ class StockOrdersService { $vehList = []; $index = 0; - $currencyInfo = $this->getCurrencyInfo($item->settlement_currency); - foreach ($item->items as $v) { // 如果已存在相同车辆,增加数量 if (isset($vehList[$v->unique_id])) { - $this->incrementVehicleCount($vehList[$v->unique_id], $currencyInfo); + $this->incrementVehicleCount($vehList[$v->unique_id]); // 拼接 remark 值 if (!empty($v->remark)) { if (!empty($vehList[$v->unique_id]['remark'])) { @@ -787,17 +777,9 @@ class StockOrdersService } continue; } - $index++; // 处理金额信息 $moneyValues = $this->processItemMoneyValues($v); - - // 处理改装信息 - // $modificationText = $this->getModificationText($v->options); - - // 利润 - // $itemProfit = empty($moneyValues['profit']['amount']) ? 0 : $moneyValues['profit']['amount']; - // 构建车辆信息 $vehList[$v->unique_id] = [ 'index' => $index, @@ -805,19 +787,10 @@ class StockOrdersService 'color_interior_snapshot' => $v->color_interior_snapshot, 'color_exterior_snapshot' => $v->color_exterior_snapshot, 'num' => 1, - // 'modify' => $modificationText, 'mileage' => $v->mileage, 'remark' => $v->remark, ] + $moneyValues; - // var_dump($vehList[$v->unique_id]); - // 添加利润信息 - // $vehList[$v->unique_id]['profit'] = [ - // 'currency' => $item->settlement_currency, - // 'amount' => $itemProfit, - // 'currency_info' => $currencyInfo['currency_symbol'] . number_format($itemProfit, 2, '.', ',') - // ]; } - return ['list' => $vehList]; } @@ -853,23 +826,9 @@ class StockOrdersService /** * 增加车辆数量并更新相关金额显示 */ - private function incrementVehicleCount(array &$vehicleData, array $currencyInfo): void + private function incrementVehicleCount(array &$vehicleData): void { $vehicleData['num'] += 1; - - // // 更新总价显示 - // if (isset($vehicleData['total_price']['amount'])) { - // $totalAmount = $vehicleData['total_price']['amount'] * $vehicleData['num']; - // $vehicleData['total_price']['currency_info'] = $currencyInfo['currency_symbol'] . number_format($totalAmount, 2, '.', ','); - // } - - // // 更新利润显示 - // if (isset($vehicleData['profit']['amount'])) { - // $profitAmount = $vehicleData['profit']['amount'] * $vehicleData['num']; - // $vehicleData['profit']['currency_info'] = $currencyInfo['currency_symbol'] . number_format($profitAmount, 2, '.', ','); - // } - - // var_dump($vehicleData); $fieldList = [ 'fob_transport_fee', From cb4a3a3cd3aec8772ab07955111f43120b630af1 Mon Sep 17 00:00:00 2001 From: mzl Date: Fri, 24 Oct 2025 15:47:46 +0800 Subject: [PATCH 2/3] Merge branch 'develop' --- app/common/service/ApprovalRecordsService.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/common/service/ApprovalRecordsService.php b/app/common/service/ApprovalRecordsService.php index 3b37365..61c026e 100644 --- a/app/common/service/ApprovalRecordsService.php +++ b/app/common/service/ApprovalRecordsService.php @@ -56,9 +56,9 @@ class ApprovalRecordsService case 'todo': if ($p['scene'] === 'todo') { - // if (!in_array(1, $request->user->role_ids)) { - // $config['where']['approver_id'] = $request->user->uid; - // } + if (!in_array(1, $request->user->role_ids)) { + $config['where']['approver_id'] = $request->user->uid; + } $config['where']['status'] = 'pending'; $config['where']['instance.status'] = 'processing'; } From e62becd30b6d394e9c991c03f03819086161ad15 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 29 Oct 2025 11:46:08 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/UploadController.php | 7 +++-- app/common/service/OssService.php | 34 ++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/common/controller/UploadController.php b/app/common/controller/UploadController.php index d90c84a..a025666 100644 --- a/app/common/controller/UploadController.php +++ b/app/common/controller/UploadController.php @@ -87,12 +87,15 @@ class UploadController } $originalName = $file->getUploadName(); + $ossservice = new OssService(); + $mimes = $ossservice->getMimeTypes(['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'zip', 'rar']); + $result = Storage::adapter('oss') ->path('x_server/' . $sceneUrl . date('Ymd')) ->size(1024*1024*5) + ->extYes($mimes) ->upload($file); - - $ossservice = new OssService(); + $data = [ 'original_name' => $originalName, diff --git a/app/common/service/OssService.php b/app/common/service/OssService.php index 72a956e..1aacc1c 100644 --- a/app/common/service/OssService.php +++ b/app/common/service/OssService.php @@ -76,4 +76,38 @@ class OssService throw new BusinessException('Delete Error: ' . $th->getMessage()); } } + + /** + * 获取对应的 MIME 类型 + */ + public function getMimeTypes($extensions) + { + $mimeMap = [ + 'jpg' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'png' => 'image/png', + 'gif' => 'image/gif', + 'bmp' => 'image/bmp', + 'webp' => 'image/webp', + 'pdf' => 'application/pdf', + 'doc' => 'application/msword', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'xls' => 'application/vnd.ms-excel', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'txt' => 'text/plain', + 'zip' => 'application/zip', + 'rar' => 'application/x-rar-compressed' + ]; + + $mimes = []; + foreach ($extensions as $ext) { + if (isset($mimeMap[$ext])) { + $mimes[] = $mimeMap[$ext]; + } + } + + return array_unique($mimes); + } } \ No newline at end of file