diff --git a/app/common/controller/StockOrderAccountsController.php b/app/common/controller/StockOrderAccountsController.php new file mode 100644 index 0000000..5bd7d57 --- /dev/null +++ b/app/common/controller/StockOrderAccountsController.php @@ -0,0 +1,33 @@ +service = new StockOrderAccountsService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + // protected function indexFormat($data) + // { + // if (isset($data['created_at'])) + // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + // if (isset($data['updated_at'])) + // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + // return $data; + // } +} \ No newline at end of file diff --git a/app/common/controller/StockOrderItemOptionsController.php b/app/common/controller/StockOrderItemOptionsController.php new file mode 100644 index 0000000..b818603 --- /dev/null +++ b/app/common/controller/StockOrderItemOptionsController.php @@ -0,0 +1,33 @@ +service = new StockOrderItemOptionsService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + // protected function indexFormat($data) + // { + // if (isset($data['created_at'])) + // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + // if (isset($data['updated_at'])) + // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + // return $data; + // } +} \ No newline at end of file diff --git a/app/common/controller/StockOrderItemsController.php b/app/common/controller/StockOrderItemsController.php new file mode 100644 index 0000000..dd2148c --- /dev/null +++ b/app/common/controller/StockOrderItemsController.php @@ -0,0 +1,33 @@ +service = new StockOrderItemsService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + // protected function indexFormat($data) + // { + // if (isset($data['created_at'])) + // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + // if (isset($data['updated_at'])) + // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + // return $data; + // } +} \ No newline at end of file diff --git a/app/common/controller/VehMoneyValueController.php b/app/common/controller/VehMoneyValueController.php new file mode 100644 index 0000000..b96d3f9 --- /dev/null +++ b/app/common/controller/VehMoneyValueController.php @@ -0,0 +1,33 @@ +service = new VehMoneyValueService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + // protected function indexFormat($data) + // { + // if (isset($data['created_at'])) + // $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + // if (isset($data['updated_at'])) + // $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + // return $data; + // } +} \ No newline at end of file diff --git a/app/common/logic/StockOrderAccountsLogic.php b/app/common/logic/StockOrderAccountsLogic.php new file mode 100644 index 0000000..b76c961 --- /dev/null +++ b/app/common/logic/StockOrderAccountsLogic.php @@ -0,0 +1,17 @@ +belongsTo(VehMoneyValue::class, 'unit_price_value_id'); } + public function handlingFee() { return $this->belongsTo(VehMoneyValue::class, 'handling_fee_value_id'); } + public function fobTransportFee() { return $this->belongsTo(VehMoneyValue::class, 'fob_transport_fee_value_id'); } + public function portMiscFee() { return $this->belongsTo(VehMoneyValue::class, 'port_misc_fee_value_id'); } + public function retrofitFee() { return $this->belongsTo(VehMoneyValue::class, 'retrofit_fee_value_id'); } + public function totalPrice() { return $this->belongsTo(VehMoneyValue::class, 'total_price_value_id'); } + + // 便捷访问器(原币种的金额) + public function getUnitPriceAmountAttribute() { return $this->unitPrice?->amount; } + public function getHandlingFeeAmountAttribute() { return $this->handlingFee?->amount; } + public function getFobTransportFeeAmountAttribute() { return $this->fobTransportFee?->amount; } + public function getPortMiscFeeAmountAttribute() { return $this->portMiscFee?->amount; } + public function getRetrofitFeeAmountAttribute() { return $this->retrofitFee?->amount; } + public function getTotalPriceAmountAttribute() { return $this->totalPrice?->amount; } + + // 便捷:按“各自 exchange_rate”换到结算币后相加(无 rate 的跳过) + public function sumToSettlement(): string + { + $list = array_filter([ + $this->unitPrice?->amountInSettlement(), + $this->handlingFee?->amountInSettlement(), + $this->fobTransportFee?->amountInSettlement(), + $this->portMiscFee?->amountInSettlement(), + $this->retrofitFee?->amountInSettlement(), + ], fn($v) => $v !== null); + + $sum = '0.00'; + foreach ($list as $v) { + $sum = bcadd($sum, (string)$v, 2); + } + return $sum; + } +} \ No newline at end of file diff --git a/app/common/model/StockOrders.php b/app/common/model/StockOrders.php index 6d48978..21239c1 100644 --- a/app/common/model/StockOrders.php +++ b/app/common/model/StockOrders.php @@ -40,7 +40,7 @@ class StockOrders extends Model /** * 允许自动填充模型字段 */ - protected $fillable = ['id', 'order_no', 'pi_no', 'biz_date', 'salesperson_id', 'salesperson_name_snapshot', 'clearance_country_id', 'clearance_country_name_snapshot', 'ali_order_no', 'customer_source_id', 'customer_source_name_snapshot', 'customer_id', 'customer_name_snapshot', 'customer_country_id', 'customer_country_name_snapshot', 'declarant_name', 'eta_ship_date', 'shipping_method', 'cif_total_amount', 'domestic_port_id', 'domestic_port_name_snapshot', 'trade_term_id', 'trade_term_name_snapshot', 'clearance_port_id', 'clearance_port_name_snapshot', 'latest_arrival_date', 'contract_exchange_rate', 'status', 'remark', 'created_at', 'updated_at', 'deleted_at']; + protected $fillable = ['id', 'order_no', 'pi_no', 'biz_date', 'salesperson_id', 'salesperson_snapshot', 'clearance_country_id', 'clearance_country_snapshot', 'ali_order_no', 'customer_source_id', 'customer_source_snapshot', 'customer_id', 'customer_snapshot', 'customer_country_id', 'customer_country_snapshot', 'declarant_name', 'eta_ship_date', 'shipping_method', 'cif_total_amount', 'domestic_port_id', 'domestic_port_snapshot', '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']; /** * 不允许自动填充模型字段 diff --git a/app/common/model/VehMoneyValue.php b/app/common/model/VehMoneyValue.php new file mode 100644 index 0000000..30fd497 --- /dev/null +++ b/app/common/model/VehMoneyValue.php @@ -0,0 +1,49 @@ +validator; + } +} \ No newline at end of file diff --git a/app/common/service/StockOrderItemOptionsService.php b/app/common/service/StockOrderItemOptionsService.php new file mode 100644 index 0000000..2e6e48e --- /dev/null +++ b/app/common/service/StockOrderItemOptionsService.php @@ -0,0 +1,31 @@ +validator; + } +} \ No newline at end of file diff --git a/app/common/service/StockOrderItemsService.php b/app/common/service/StockOrderItemsService.php new file mode 100644 index 0000000..9130bdc --- /dev/null +++ b/app/common/service/StockOrderItemsService.php @@ -0,0 +1,31 @@ +validator; + } +} \ No newline at end of file diff --git a/app/common/service/VehMoneyValueService.php b/app/common/service/VehMoneyValueService.php new file mode 100644 index 0000000..361aa55 --- /dev/null +++ b/app/common/service/VehMoneyValueService.php @@ -0,0 +1,31 @@ +validator; + } +} \ No newline at end of file diff --git a/app/common/service/VehVehicleSkuService.php b/app/common/service/VehVehicleSkuService.php index ca25040..d2679ab 100644 --- a/app/common/service/VehVehicleSkuService.php +++ b/app/common/service/VehVehicleSkuService.php @@ -34,52 +34,52 @@ class VehVehicleSkuService } - // 枚举 - private const MAPS = [ - 'BODY' => [ - 'SEDAN' => '三厢轿车', 'SUV'=>'SUV', 'HB'=>'两厢/掀背', 'MPV'=>'MPV', 'PICKUP'=>'皮卡' - ], - 'DRIVE' => [ - 'FWD'=>'前驱', 'RWD'=>'后驱', 'AWD'=>'四驱(AWD)', '4WD'=>'四驱(4WD)' - ], - 'MOTOR_LAYOUT' => [ - 'FWD'=>'前置单电机', 'RWD'=>'后置单电机', 'AWD'=>'双电机四驱', 'DM-I'=>'DM-i', 'DM-P'=>'DM-p' - ], - 'FUEL' => [ - 'GAS'=>'汽油', 'HEV'=>'油电混动', 'PHEV'=>'插电混动', 'EV'=>'纯电', 'EREV'=>'增程' - ], - 'TRANS' => [ - 'MT'=>'手动', 'AT'=>'自动', 'CVT'=>'无级', 'DCT'=>'双离合', '1SPEED'=>'单速' - ], - 'RANGE_STD' => [ - 'CLTC'=>'CLTC', 'WLTP'=>'WLTP', 'EPA'=>'EPA', 'NEDC'=>'NEDC' - ], - 'EMISSION' => [ - 'CHN6'=>'国六', 'EURO6'=>'欧6', 'EPA'=>'美国EPA' - ], - ]; + // // 枚举 + // private const MAPS = [ + // 'BODY' => [ + // 'SEDAN' => '三厢轿车', 'SUV'=>'SUV', 'HB'=>'两厢/掀背', 'MPV'=>'MPV', 'PICKUP'=>'皮卡' + // ], + // 'DRIVE' => [ + // 'FWD'=>'前驱', 'RWD'=>'后驱', 'AWD'=>'四驱(AWD)', '4WD'=>'四驱(4WD)' + // ], + // 'MOTOR_LAYOUT' => [ + // 'FWD'=>'前置单电机', 'RWD'=>'后置单电机', 'AWD'=>'双电机四驱', 'DM-I'=>'DM-i', 'DM-P'=>'DM-p' + // ], + // 'FUEL' => [ + // 'GAS'=>'汽油', 'HEV'=>'油电混动', 'PHEV'=>'插电混动', 'EV'=>'纯电', 'EREV'=>'增程' + // ], + // 'TRANS' => [ + // 'MT'=>'手动', 'AT'=>'自动', 'CVT'=>'无级', 'DCT'=>'双离合', '1SPEED'=>'单速' + // ], + // 'RANGE_STD' => [ + // 'CLTC'=>'CLTC', 'WLTP'=>'WLTP', 'EPA'=>'EPA', 'NEDC'=>'NEDC' + // ], + // 'EMISSION' => [ + // 'CHN6'=>'国六', 'EURO6'=>'欧6', 'EPA'=>'美国EPA' + // ], + // ]; - // *_code取中文 - public function label(string $dict, ?string $code): ?string - { - if ($code === null || $code === '') return null; - $dict = strtoupper($dict); - $code = strtoupper($code); - return self::MAPS[$dict][$code] ?? $code; - } + // // *_code取中文 + // public function label(string $dict, ?string $code): ?string + // { + // if ($code === null || $code === '') return null; + // $dict = strtoupper($dict); + // $code = strtoupper($code); + // return self::MAPS[$dict][$code] ?? $code; + // } - // 静态映射把 *_code → 中文 - private function backfill(array $d): array - { - $d['body_type'] = $this->label('BODY', $d['body_type_code']); - $d['drive_type'] = $this->label('DRIVE', $d['drive_type_code']); - $d['motor_layout'] = $this->label('MOTOR_LAYOUT', $d['motor_layout_code']); - $d['fuel_type'] = $this->label('FUEL', $d['fuel_type_code']); - $d['transmission'] = $this->label('TRANS', $d['transmission_code']); - $d['range_std'] = $this->label('RANGE_STD', $d['range_std_code']); - $d['emission_std'] = $this->label('EMISSION', $d['emission_std_code']); - return $d; - } + // // 静态映射把 *_code → 中文 + // private function backfill(array $d): array + // { + // $d['body_type'] = $this->label('BODY', $d['body_type_code']); + // $d['drive_type'] = $this->label('DRIVE', $d['drive_type_code']); + // $d['motor_layout'] = $this->label('MOTOR_LAYOUT', $d['motor_layout_code']); + // $d['fuel_type'] = $this->label('FUEL', $d['fuel_type_code']); + // $d['transmission'] = $this->label('TRANS', $d['transmission_code']); + // $d['range_std'] = $this->label('RANGE_STD', $d['range_std_code']); + // $d['emission_std'] = $this->label('EMISSION', $d['emission_std_code']); + // return $d; + // } protected function buildQueryConfig(Request $request, string $scene = 'default'): array { diff --git a/app/common/validate/StockOrderAccountsValidate.php b/app/common/validate/StockOrderAccountsValidate.php new file mode 100644 index 0000000..8c63773 --- /dev/null +++ b/app/common/validate/StockOrderAccountsValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/validate/StockOrderItemOptionsValidate.php b/app/common/validate/StockOrderItemOptionsValidate.php new file mode 100644 index 0000000..4f3c522 --- /dev/null +++ b/app/common/validate/StockOrderItemOptionsValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/validate/StockOrderItemsValidate.php b/app/common/validate/StockOrderItemsValidate.php new file mode 100644 index 0000000..501e690 --- /dev/null +++ b/app/common/validate/StockOrderItemsValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/validate/VehMoneyValueValidate.php b/app/common/validate/VehMoneyValueValidate.php new file mode 100644 index 0000000..185ffa4 --- /dev/null +++ b/app/common/validate/VehMoneyValueValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file